{"id":468,"date":"2008-05-02T09:17:49","date_gmt":"2008-05-02T13:17:49","guid":{"rendered":"http:\/\/www.dr-chuck.com\/wordpress\/?p=468"},"modified":"2011-12-17T12:26:16","modified_gmt":"2011-12-17T16:26:16","slug":"note-to-self-sak-11544-destined-for-2-5-x","status":"publish","type":"post","link":"https:\/\/www.dr-chuck.com\/csev-blog\/2008\/05\/note-to-self-sak-11544-destined-for-2-5-x\/","title":{"rendered":"Note To Self &#8211; SAK-11544 destined for 2-5-x"},"content":{"rendered":"<p>I finally got back to this!<br \/>\nStuff to merge for SAK-11544<br \/>\nI took a copy of the 2-5-x code and reapplied the mods to that code and tested it.  I attach the file that should slide right into 2-5-x.<br \/>\nsearch-impl\/impl\/src\/java\/org\/sakaiproject\/search\/component\/adapter\/message\/MessageContentProducer.java<br \/>\nActually most of the differences were in formatting &#8211; someone had checked out the code &#8211; made a small mod but reformatted the code w.r.t. line ends and checked it back in.   So it looks like there are lots of differences &#8211; it was not a refactor &#8211; just a reformat :)<br \/>\nThis code should go in and make pretty diffs.<\/p>\n<p><!--more--><br \/>\n$ svn diff<br \/>\nIndex: search-impl\/impl\/src\/java\/org\/sakaiproject\/search\/component\/adapter\/message\/MessageContentProducer.java<br \/>\n===================================================================<br \/>\n&#8212; search-impl\/impl\/src\/java\/org\/sakaiproject\/search\/component\/adapter\/message\/MessageContentProducer.java\t(revision 45952)<br \/>\n+++ search-impl\/impl\/src\/java\/org\/sakaiproject\/search\/component\/adapter\/message\/MessageContentProducer.java\t(working copy)<br \/>\n@@ -49,6 +49,7 @@<br \/>\nimport org.sakaiproject.search.component.Messages;<br \/>\nimport org.sakaiproject.search.model.SearchBuilderItem;<br \/>\nimport org.sakaiproject.search.util.HTMLParser;<br \/>\n+import org.sakaiproject.javax.PagingPosition;<br \/>\n\/**<br \/>\n* @author ieb<br \/>\n@@ -499,17 +500,22 @@<br \/>\nfinal Iterator ci = l.iterator();<br \/>\nreturn new Iterator()<br \/>\n{<br \/>\n&#8211;\t\t\tIterator mi = null;<br \/>\n+\t\t\tMessageChannel mc = null;<br \/>\n+\t\t\tint messageCount = -1;<br \/>\n+\t\t\tint nextMessage = -1;  \/\/ Index overall messages &#8211; Starts at 1<br \/>\n+\t\t\tList messages = null;<br \/>\n+\t\t\tint listPos = 0;  \/\/ Index each chunk &#8211; Starts at zero<br \/>\n+\t\t\tint chunkSize = 100;  \/\/ Retrieve 100 at a time<br \/>\npublic boolean hasNext()<br \/>\n{<br \/>\n&#8211;\t\t\t\tif (mi == null)<br \/>\n+\t\t\t\tif (mc == null)<br \/>\n{<br \/>\nreturn nextIterator();<br \/>\n}<br \/>\nelse<br \/>\n{<br \/>\n&#8211;\t\t\t\t\tif (mi.hasNext())<br \/>\n+\t\t\t\t\tif (messageCount > 1 &#038;&#038; nextMessage &lt;= messageCount)<br \/>\n{<br \/>\nreturn true;<br \/>\n}<br \/>\n@@ -528,13 +534,12 @@<br \/>\nString chanellId = (String) ci.next();<br \/>\ntry<br \/>\n{<br \/>\n&#8211;\t\t\t\t\t\tMessageChannel c = messageService<br \/>\n&#8211;\t\t\t\t\t\t\t\t.getChannel(messageService.channelReference(<br \/>\n&#8211;\t\t\t\t\t\t\t\t\t\tcontext, chanellId));<br \/>\n&#8211;\t\t\t\t\t\tList messages = c.getMessages(null, true);<br \/>\n&#8211;\t\t\t\t\t\tmi = messages.iterator();<br \/>\n&#8211;\t\t\t\t\t\tif (mi.hasNext())<br \/>\n+\t\t\t\t\t\tmc = messageService.getChannel(messageService<br \/>\n+\t\t\t\t\t\t\t\t.channelReference(context, chanellId));<br \/>\n+\t\t\t\t\t\tmessageCount = mc.getCount();<br \/>\n+\t\t\t\t\t\tif (messageCount > 0 )<br \/>\n{<br \/>\n+\t\t\t\t\t\t\tnextMessage = 1;  \/\/ Pager starts at 1<br \/>\nreturn true;<br \/>\n}<br \/>\n}<br \/>\n@@ -542,22 +547,56 @@<br \/>\n{<br \/>\nex.printStackTrace();<br \/>\nlog.warn(&#8220;Failed to get channel &#8221; + chanellId); \/\/$NON-NLS-1$<br \/>\n&#8211;<br \/>\n}<br \/>\n}<br \/>\n+\t\t\t\tmc = null;<br \/>\n+\t\t\t\tnextMessage = -1;<br \/>\n+\t\t\t\tmessageCount = -1;<br \/>\nreturn false;<br \/>\n}<br \/>\n+\t\t\t\/*<br \/>\n+\t\t\t * Loop though the messages in the channel grabbing them<br \/>\n+\t\t\t * in chunkSize chunks for efficiency.<br \/>\n+\t\t\t *\/<br \/>\npublic Object next()<br \/>\n{<br \/>\n&#8211;\t\t\t\tMessage m = (Message) mi.next();<br \/>\n&#8211;\t\t\t\treturn m.getReference();<br \/>\n+\t\t\t\tif ( messages != null &#038;&#038; listPos >= 0 &#038;&#038; listPos &lt; messages.size() )<br \/>\n+\t\t\t\t{<br \/>\n+\t\t\t\t\tMessage m = (Message) messages.get(listPos);<br \/>\n+\t\t\t\t\tnextMessage = nextMessage + 1;<br \/>\n+\t\t\t\t\tlistPos = listPos + 1;<br \/>\n+\t\t\t\t\treturn m.getReference();<br \/>\n+\t\t\t\t}<br \/>\n+<br \/>\n+\t\t\t\t\/\/ Retrieve the next &#8220;chunk&#8221;<br \/>\n+\t\t\t\tPagingPosition pages = new PagingPosition(nextMessage, (nextMessage + chunkSize &#8211; 1));<br \/>\n+\t\t\t\ttry<br \/>\n+\t\t\t\t{<br \/>\n+\t\t\t\t\tmessages = mc.getMessages(null, true, pages);<br \/>\n+\t\t\t\t\tif ( messages != null &#038;&#038; messages.size() > 0 )<br \/>\n+\t\t\t\t\t{<br \/>\n+\t\t\t\t\t\tlistPos = 0;<br \/>\n+\t\t\t\t\t\tMessage m = (Message) messages.get(listPos);<br \/>\n+\t\t\t\t\t\tnextMessage = nextMessage + 1;<br \/>\n+\t\t\t\t\t\tlistPos = listPos + 1;<br \/>\n+\t\t\t\t\t\treturn m.getReference();<br \/>\n+\t\t\t\t\t}<br \/>\n+\t\t\t\t}<br \/>\n+\t\t\t\tcatch (Exception ex)<br \/>\n+\t\t\t\t{<br \/>\n+\t\t\t\t\tex.printStackTrace();<br \/>\n+\t\t\t\t\tlog.warn(&#8220;Failed to get message &#8221; + nextMessage); \/\/$NON-NLS-1$<br \/>\n+<br \/>\n+\t\t\t\t}<br \/>\n+\t\t\t\t\/\/ We are done looping through this channel<br \/>\n+\t\t\t\tnextMessage = messageCount + 1;<br \/>\n+\t\t\t\treturn null;<br \/>\n}<br \/>\npublic void remove()<br \/>\n{<br \/>\n&#8211;\t\t\t\tthrow new UnsupportedOperationException(<br \/>\n&#8211;\t\t\t\t\t\t&#8220;Remove not implemented&#8221;); \/\/$NON-NLS-1$<br \/>\n+\t\t\t\tthrow new UnsupportedOperationException(&#8220;Remove not implemented&#8221;); \/\/$NON-NLS-1$<br \/>\n}<br \/>\n};<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I finally got back to this! Stuff to merge for SAK-11544 I took a copy of the 2-5-x code and reapplied the mods to that code and tested it. I attach the file that should slide right into 2-5-x. search-impl\/impl\/src\/java\/org\/sakaiproject\/search\/component\/adapter\/message\/MessageContentProducer.java Actually most of the differences were in formatting &#8211; someone had checked out the code [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-468","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/www.dr-chuck.com\/csev-blog\/wp-json\/wp\/v2\/posts\/468","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dr-chuck.com\/csev-blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dr-chuck.com\/csev-blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dr-chuck.com\/csev-blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dr-chuck.com\/csev-blog\/wp-json\/wp\/v2\/comments?post=468"}],"version-history":[{"count":2,"href":"https:\/\/www.dr-chuck.com\/csev-blog\/wp-json\/wp\/v2\/posts\/468\/revisions"}],"predecessor-version":[{"id":2575,"href":"https:\/\/www.dr-chuck.com\/csev-blog\/wp-json\/wp\/v2\/posts\/468\/revisions\/2575"}],"wp:attachment":[{"href":"https:\/\/www.dr-chuck.com\/csev-blog\/wp-json\/wp\/v2\/media?parent=468"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dr-chuck.com\/csev-blog\/wp-json\/wp\/v2\/categories?post=468"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dr-chuck.com\/csev-blog\/wp-json\/wp\/v2\/tags?post=468"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}