19 package org.turro.user.content;
21 import java.util.Collections;
23 import java.util.TreeSet;
24 import org.turro.string.Strings;
25 import org.turro.elephant.context.Application;
26 import org.turro.elephant.context.IConstructor;
27 import org.turro.marker.ElephantMarker;
28 import org.turro.plugin.contacts.IContact;
29 import org.turro.reflection.ClassNames;
30 import org.turro.reflection.Reflections;
38 private static final String USER_CONTENT_CONTEXT =
"elusrctx_";
42 return marker.
parse(
"widgets/user",
"userContent");
50 if(contact ==
null || !contact.
isValid())
return Collections.EMPTY_SET;
51 Set<IElephantUserContent>
set = (Set<IElephantUserContent>) constructor.
getSessionAttribute(USER_CONTENT_CONTEXT + contact.
getId());
52 if(fresh || (
set ==
null)) {
53 set = loadContents(contact);
60 Set<String>
set =
new TreeSet<>();
62 if(!Strings.isBlank(euc.render(constructor))) {
63 set.addAll(euc.getTags());
81 private static Set<IElephantUserContent> loadContents(
IContact contact) {
82 Set<IElephantUserContent>
set =
new TreeSet<>();
83 for(String className : ClassNames.cached().byAnnotation(
ElephantUserContent.class.getName())) {
90 if(instance !=
null) {
97 private UserContents() {
IConstructor getConstructor()
static IContact getUser()
static Application getApplication()
String parse(String rootTmpl, String tmpl)
static void reset(IConstructor constructor, IContact contact)
static String parseContents(IConstructor constructor)
static Set< IElephantUserContent > getContents(IConstructor constructor, IContact contact, boolean fresh)
static Set< IElephantUserContent > getContents(IConstructor constructor, IContact contact)
static Set< String > getTags(IConstructor constructor, IContact contact)
void setSessionAttribute(String key, Object value)
Object getSessionAttribute(String key)