BrightSide Workbench Full Report + Source Code
org.turro.message.MessageQueue Class Reference
Inheritance diagram for org.turro.message.MessageQueue:
Collaboration diagram for org.turro.message.MessageQueue:

Public Member Functions

String getIntervalCall (IConstructor constructor)
 
 MessageQueue ()
 
- Public Member Functions inherited from org.turro.elephant.direct.AbstractDirectContentCtrl
 AbstractDirectContentCtrl (String tmplRoot)
 
String createFormAction ()
 
String createPOST (String values)
 
String getAjaxSubmitUrl (String containerId)
 
String getAjaxUrl (String containerId, String values)
 
String getAjaxUrl (String containerId, KeyValueMap values)
 
String getAjaxEvalUrl (KeyValueMap values)
 
String createRightNowURL (String values)
 
String createRightNowURL (KeyValueMap values)
 
String createLinkTo (String link, KeyValueMap values)
 
String createURL ()
 
String createURL (IConstructor constructor, String values)
 
String createURL (IConstructor constructor, String values, int daysValid)
 
String createURL (IConstructor constructor, String values, int daysValid, boolean withDomain)
 
String createURL (IConstructor constructor, IContact recipe, String values, int daysValid, boolean withDomain)
 
String createURL (IConstructor constructor, IContact recipe, KeyValueMap values, int daysValid, boolean withDomain)
 
void setTemplate (String template)
 
void render (IConstructor constructor)
 
String parse (IConstructor constructor)
 
boolean itsMe (String id)
 
boolean myTurn (HttpServletRequest request)
 
void execute (ServletContext context, HttpServletRequest request, HttpServletResponse response)
 
void execute (IConstructor constructor)
 

Static Public Member Functions

static void pushMessage (IContact contact, String msg)
 
static String pollMessage (IContact contact)
 
static boolean hasMessage (IContact contact)
 
static void pushMessage (String idContact, String msg)
 
static String pollMessage (String idContact)
 
static boolean hasMessage (String idContact)
 
static void pushGenerics (String idContact)
 
static BlockingQueue< String > getQueue (IContact contact)
 
static BlockingQueue< String > getQueue (String idContact)
 

Protected Member Functions

String getIdentifier ()
 
void prepareMarker (ElephantMarker marker)
 
void prepareCleanMarker (ElephantMarker marker, KeyValueMap map)
 
void doExecute (IConstructor constructor, KeyValueMap map)
 
- Protected Member Functions inherited from org.turro.elephant.direct.AbstractDirectContentCtrl
String getRedirContext (IConstructor constructor, boolean withDomain)
 
ElephantMarker getMarker (IConstructor constructor)
 
ElephantMarker getCleanMarkerFrom (IConstructor constructor)
 
void addContainerId (ElephantMarker marker, boolean container)
 
String getTmplRoot ()
 
String getTemplate ()
 
void writeMarkerToResponse (IConstructor constructor, KeyValueMap map)
 
void writeMarkerToResponse (IConstructor constructor, KeyValueMap map, Map extra)
 
void setNeedsUser (boolean needsUser)
 

Additional Inherited Members

- Protected Attributes inherited from org.turro.elephant.direct.AbstractDirectContentCtrl
String template = "full"
 

Detailed Description

Author
Lluis TurrĂ³ Cutiller lluis.nosp@m.@tur.nosp@m.ro.or.nosp@m.g

Definition at line 51 of file MessageQueue.java.

Constructor & Destructor Documentation

◆ MessageQueue()

org.turro.message.MessageQueue.MessageQueue ( )

Definition at line 125 of file MessageQueue.java.

125  {
126  super("widgets/messages");
127  setNeedsUser(true);
128  }

Member Function Documentation

◆ doExecute()

void org.turro.message.MessageQueue.doExecute ( IConstructor  constructor,
KeyValueMap  map 
)
protected

Reimplemented from org.turro.elephant.direct.AbstractDirectContentCtrl.

Definition at line 147 of file MessageQueue.java.

147  {
148  String type = map.get("type"),
149  userId = map.get("userId");
150  if("query".equals(type) && !Strings.isBlank(userId)) {
151  Set<String> messages = new HashSet<>();
152  while(hasMessage(userId)) {
153  messages.add(pollMessage(userId));
154  }
155  if(!messages.isEmpty()) {
156  HashMap extra = new HashMap();
157  extra.put("messages", messages);
158  writeMarkerToResponse(constructor, map, extra);
159  }
160  }
161  }
void writeMarkerToResponse(IConstructor constructor, KeyValueMap map)
static boolean hasMessage(IContact contact)
static String pollMessage(IContact contact)

◆ getIdentifier()

String org.turro.message.MessageQueue.getIdentifier ( )
protected

Reimplemented from org.turro.elephant.direct.AbstractDirectContentCtrl.

Definition at line 131 of file MessageQueue.java.

131  {
132  return MessageQueue.class.getAnnotation(DirectContent.class).identifier();
133  }

◆ getIntervalCall()

String org.turro.message.MessageQueue.getIntervalCall ( IConstructor  constructor)

Definition at line 77 of file MessageQueue.java.

77  {
78  IContact user = constructor.getUser();
79  if(user != null) {
80  KeyValueMap map = new KeyValueMap();
81  map.put("userId", user.getId());
82  map.put("type", "query");
83  return getAjaxEvalUrl(map);
84  } else {
85  return null;
86  }
87  }
Here is the call graph for this function:

◆ getQueue() [1/2]

static BlockingQueue<String> org.turro.message.MessageQueue.getQueue ( IContact  contact)
static

Definition at line 115 of file MessageQueue.java.

115  {
116  return getQueue(contact.getId());
117  }
static BlockingQueue< String > getQueue(IContact contact)
Here is the call graph for this function:

◆ getQueue() [2/2]

static BlockingQueue<String> org.turro.message.MessageQueue.getQueue ( String  idContact)
static

Definition at line 119 of file MessageQueue.java.

119  {
120  return QUEUE_MAP.computeIfAbsent(idContact, k -> new LinkedBlockingQueue<String>());
121  }

◆ hasMessage() [1/2]

static boolean org.turro.message.MessageQueue.hasMessage ( IContact  contact)
static

Definition at line 61 of file MessageQueue.java.

61  {
62  return !(getQueue(contact).isEmpty());
63  }

◆ hasMessage() [2/2]

static boolean org.turro.message.MessageQueue.hasMessage ( String  idContact)
static

Definition at line 73 of file MessageQueue.java.

73  {
74  return !(getQueue(idContact).isEmpty());
75  }

◆ pollMessage() [1/2]

static String org.turro.message.MessageQueue.pollMessage ( IContact  contact)
static

Definition at line 57 of file MessageQueue.java.

57  {
58  return getQueue(contact).poll();
59  }

◆ pollMessage() [2/2]

static String org.turro.message.MessageQueue.pollMessage ( String  idContact)
static

Definition at line 69 of file MessageQueue.java.

69  {
70  return getQueue(idContact).poll();
71  }

◆ prepareCleanMarker()

void org.turro.message.MessageQueue.prepareCleanMarker ( ElephantMarker  marker,
KeyValueMap  map 
)
protected

Reimplemented from org.turro.elephant.direct.AbstractDirectContentCtrl.

Definition at line 141 of file MessageQueue.java.

141  {
142  setTemplate("toast");
143  marker.putAll(map);
144  }
Here is the call graph for this function:

◆ prepareMarker()

void org.turro.message.MessageQueue.prepareMarker ( ElephantMarker  marker)
protected

Reimplemented from org.turro.elephant.direct.AbstractDirectContentCtrl.

Definition at line 136 of file MessageQueue.java.

136  {
137  setTemplate("init");
138  }

◆ pushGenerics()

static void org.turro.message.MessageQueue.pushGenerics ( String  idContact)
static

Definition at line 93 of file MessageQueue.java.

93  {
94  Path folder = Path.of(ElephantContext.getRealPath(GENERIC_MESSAGE_FOLDER));
95  if(Files.exists(folder)) {
96  PathMatcher matcher = FileSystems.getDefault().getPathMatcher("glob:**.txt");
97  try (Stream<Path> entries = Files.list(folder).filter(p -> matcher.matches(p))) {
98  entries.forEach(file -> {
99  try {
100  pushMessage(idContact, FileUtil.getContent(file.toFile()));
101  } catch (IOException ex) {
102  Logger.getLogger(MessageQueue.class.getName()).log(Level.SEVERE, ElephantContext.logMsg(null), ex);
103  }
104  });
105  } catch (IOException ex) {
106  Logger.getLogger(MessageQueue.class.getName()).log(Level.SEVERE, ElephantContext.logMsg(null), ex);
107  }
108  }
109  }
static void pushMessage(IContact contact, String msg)
Here is the call graph for this function:

◆ pushMessage() [1/2]

static void org.turro.message.MessageQueue.pushMessage ( IContact  contact,
String  msg 
)
static

Definition at line 53 of file MessageQueue.java.

53  {
54  getQueue(contact).add(msg);
55  }
Here is the caller graph for this function:

◆ pushMessage() [2/2]

static void org.turro.message.MessageQueue.pushMessage ( String  idContact,
String  msg 
)
static

Definition at line 65 of file MessageQueue.java.

65  {
66  getQueue(idContact).add(msg);
67  }

The documentation for this class was generated from the following file: