use of org.olat.user.HomePageConfigManager in project openolat by klemens.
the class IdentityDocument method createDocument.
/**
* Factory method to create a new IdentityDocument
* @param searchResourceContext
* @param wikiPage
* @return
*/
public static Document createDocument(SearchResourceContext searchResourceContext, Identity identity) {
UserManager userMgr = UserManager.getInstance();
User user = identity.getUser();
HomePageConfigManager homepageMgr = HomePageConfigManagerImpl.getInstance();
HomePageConfig publishConfig = homepageMgr.loadConfigFor(identity.getName());
IdentityDocument identityDocument = new IdentityDocument();
identityDocument.setTitle(identity.getName());
identityDocument.setCreatedDate(user.getCreationDate());
// loop through all user properties and collect the content string and the last modified
List<UserPropertyHandler> userPropertyHanders = userMgr.getUserPropertyHandlersFor(IdentityDocument.class.getName(), false);
StringBuilder content = new StringBuilder();
for (UserPropertyHandler userPropertyHandler : userPropertyHanders) {
String propertyName = userPropertyHandler.getName();
// only index fields the user has published!
if (publishConfig.isEnabled(propertyName)) {
String value = user.getProperty(propertyName, I18nModule.getDefaultLocale());
if (value != null) {
content.append(value).append(" ");
}
}
}
// user text
String text = publishConfig.getTextAboutMe();
if (StringHelper.containsNonWhitespace(text)) {
text = FilterFactory.getHtmlTagsFilter().filter(text);
content.append(text).append(' ');
}
// finally use the properties as the content for this identity
if (content.length() > 0) {
identityDocument.setContent(content.toString());
}
identityDocument.setResourceUrl(searchResourceContext.getResourceUrl());
identityDocument.setDocumentType(searchResourceContext.getParentContextType());
identityDocument.setCssIcon(CSSHelper.CSS_CLASS_USER);
if (log.isDebug())
log.debug(identityDocument.toString());
return identityDocument.getLuceneDocument();
}
use of org.olat.user.HomePageConfigManager in project OpenOLAT by OpenOLAT.
the class IdentityDocument method createDocument.
/**
* Factory method to create a new IdentityDocument
* @param searchResourceContext
* @param wikiPage
* @return
*/
public static Document createDocument(SearchResourceContext searchResourceContext, Identity identity) {
UserManager userMgr = UserManager.getInstance();
User user = identity.getUser();
HomePageConfigManager homepageMgr = HomePageConfigManagerImpl.getInstance();
HomePageConfig publishConfig = homepageMgr.loadConfigFor(identity.getName());
IdentityDocument identityDocument = new IdentityDocument();
identityDocument.setTitle(identity.getName());
identityDocument.setCreatedDate(user.getCreationDate());
// loop through all user properties and collect the content string and the last modified
List<UserPropertyHandler> userPropertyHanders = userMgr.getUserPropertyHandlersFor(IdentityDocument.class.getName(), false);
StringBuilder content = new StringBuilder();
for (UserPropertyHandler userPropertyHandler : userPropertyHanders) {
String propertyName = userPropertyHandler.getName();
// only index fields the user has published!
if (publishConfig.isEnabled(propertyName)) {
String value = user.getProperty(propertyName, I18nModule.getDefaultLocale());
if (value != null) {
content.append(value).append(" ");
}
}
}
// user text
String text = publishConfig.getTextAboutMe();
if (StringHelper.containsNonWhitespace(text)) {
text = FilterFactory.getHtmlTagsFilter().filter(text);
content.append(text).append(' ');
}
// finally use the properties as the content for this identity
if (content.length() > 0) {
identityDocument.setContent(content.toString());
}
identityDocument.setResourceUrl(searchResourceContext.getResourceUrl());
identityDocument.setDocumentType(searchResourceContext.getParentContextType());
identityDocument.setCssIcon(CSSHelper.CSS_CLASS_USER);
if (log.isDebug())
log.debug(identityDocument.toString());
return identityDocument.getLuceneDocument();
}
Aggregations