@@ -84,32 +84,33 @@ private NodeViewAcl getNodeViewAcl() {
8484 @ Override
8585 public void process (Element elm , JID actorJID , IQ reqIQ , Element rsm )
8686 throws Exception {
87- node = elm .attributeValue ("node" );
88- requestIq = reqIQ ;
89- reply = IQ .createResultIQ (reqIQ );
90- element = elm ;
87+ node = elm .attributeValue ("node" );
88+ requestIq = reqIQ ;
89+ reply = IQ .createResultIQ (reqIQ );
90+ element = elm ;
9191 resultSetManagement = rsm ;
9292
9393 if (false == channelManager .isLocalJID (requestIq .getFrom ())) {
94- reply .getElement ().addAttribute ("remote-server-discover" , "false" );
95- }
94+ reply .getElement ().addAttribute ("remote-server-discover" , "false" );
95+ }
96+
97+ isSubscriptionsNode = node .substring (node .length () - 13 ).equals (
98+ "subscriptions" );
9699
97- isSubscriptionsNode = node .substring (node .length () - 13 ).equals ("subscriptions" );
98-
99100 boolean isCached = false ;
100101 if (true == isSubscriptionsNode ) {
101102 isCached = channelManager .nodeHasSubscriptions (node );
102103 } else {
103104 isCached = channelManager .isCachedNode (node );
104105 }
105-
106+
106107 fetchersJid = requestIq .getFrom ();
107108
108- if (false == channelManager .isLocalNode (node )
109- && ( false == isCached )) {
110- logger . debug ( "Node " + node + " is remote and not cached, off to get some data" );
109+ if (false == channelManager .isLocalNode (node ) && ( false == isCached )) {
110+ logger . debug ( "Node " + node
111+ + " is remote and not cached, off to get some data" );
111112 makeRemoteRequest ();
112- return ;
113+ return ;
113114 }
114115
115116 try {
@@ -119,7 +120,7 @@ public void process(Element elm, JID actorJID, IQ reqIQ, Element rsm)
119120 outQueue .put (reply );
120121 return ;
121122 }
122-
123+
123124 if (actorJID != null ) {
124125 fetchersJid = actorJID ;
125126 }
@@ -130,9 +131,10 @@ public void process(Element elm, JID actorJID, IQ reqIQ, Element rsm)
130131 }
131132 xmlReader = new SAXReader ();
132133 if (null == element .element ("item" )) {
133- getItems ();
134+ getItems ();
134135 } else {
135- if (false == getItem ()) return ;
136+ if (false == getItem ())
137+ return ;
136138 }
137139 } catch (NodeStoreException e ) {
138140 setErrorCondition (PacketError .Type .wait ,
@@ -142,13 +144,15 @@ public void process(Element elm, JID actorJID, IQ reqIQ, Element rsm)
142144 }
143145
144146 private boolean getItem () throws Exception {
145- NodeItem nodeItem = channelManager .getNodeItem (node , element .element ("item" ).attributeValue ("id" ));
146- if (null == nodeItem ) {
147+ NodeItem nodeItem = channelManager .getNodeItem (node ,
148+ element .element ("item" ).attributeValue ("id" ));
149+ if (null == nodeItem ) {
147150 if (false == channelManager .isLocalNode (node )) {
148- makeRemoteRequest ();
149- return false ;
151+ makeRemoteRequest ();
152+ return false ;
150153 }
151- setErrorCondition (PacketError .Type .cancel , PacketError .Condition .item_not_found );
154+ setErrorCondition (PacketError .Type .cancel ,
155+ PacketError .Condition .item_not_found );
152156 return true ;
153157 }
154158 Element pubsub = reply .getElement ().addElement ("pubsub" );
@@ -161,11 +165,11 @@ private boolean getItem() throws Exception {
161165 private void makeRemoteRequest () throws InterruptedException {
162166 requestIq .setTo (new JID (node .split ("/" )[2 ]).getDomain ());
163167 if (null == requestIq .getElement ().element ("pubsub" ).element ("actor" )) {
164- Element actor = requestIq .getElement ().element ("pubsub" )
165- .addElement ("actor" , JabberPubsub .NS_BUDDYCLOUD );
166- actor .addText (requestIq .getFrom ().toBareJID ());
168+ Element actor = requestIq .getElement ().element ("pubsub" )
169+ .addElement ("actor" , JabberPubsub .NS_BUDDYCLOUD );
170+ actor .addText (requestIq .getFrom ().toBareJID ());
167171 }
168- outQueue .put (requestIq );
172+ outQueue .put (requestIq );
169173 }
170174
171175 private boolean nodeExists () throws NodeStoreException {
@@ -206,15 +210,20 @@ private void getItems() throws Exception {
206210 if (after != null ) {
207211 try {
208212 // Try and parse it as a global item id
209- GlobalItemID afterGlobalItemID = GlobalItemIDImpl .fromString (after .getTextTrim ());
213+ GlobalItemID afterGlobalItemID = GlobalItemIDImpl
214+ .fromString (after .getTextTrim ());
210215 afterItemId = afterGlobalItemID .getItemID ();
211-
216+
212217 // Check it's for the correct node
213- if (!afterGlobalItemID .getNodeID ().equals (node )) {
214- createExtendedErrorReply (Type .modify , Condition .item_not_found , "RSM 'after' specifies an unexpected NodeID: " + afterGlobalItemID .getNodeID ());
218+ if (!afterGlobalItemID .getNodeID ().equals (node )) {
219+ createExtendedErrorReply (Type .modify ,
220+ Condition .item_not_found ,
221+ "RSM 'after' specifies an unexpected NodeID: "
222+ + afterGlobalItemID .getNodeID ());
215223 }
216- } catch (IllegalArgumentException e ) {
217- // If the after isn't a valid 'tag:...' then it might just be a straight ItemID
224+ } catch (IllegalArgumentException e ) {
225+ // If the after isn't a valid 'tag:...' then it might just
226+ // be a straight ItemID
218227 afterItemId = after .getTextTrim ();
219228 }
220229 }
@@ -235,12 +244,12 @@ private void getItems() throws Exception {
235244 }
236245
237246 if ((false == channelManager .isLocalNode (node ))
238- && (0 == rsmEntriesCount )) {
247+ && (0 == rsmEntriesCount )) {
239248 logger .debug ("No results in cache for remote node, so "
240- + "we're going federated to get more" );
241- makeRemoteRequest ();
242- return ;
243- }
249+ + "we're going federated to get more" );
250+ makeRemoteRequest ();
251+ return ;
252+ }
244253
245254 if ((resultSetManagement != null )
246255 || (totalEntriesCount > maxItemsToReturn )) {
@@ -317,15 +326,15 @@ private int getNodeItems(Element items, int maxItemsToReturn,
317326 while (itemIt .hasNext ()) {
318327 ++rsmEntriesCount ;
319328 NodeItem nodeItem = itemIt .next ();
320-
329+
321330 if (firstItem == null ) {
322331 firstItem = nodeItem .getId ();
323332 }
324333 addItemToResponse (nodeItem , items );
325334 lastItem = nodeItem .getId ();
326335 }
327- logger .debug ("Including RSM there are " + rsmEntriesCount
328- + " items for node " + node );
336+ logger .debug ("Including RSM there are " + rsmEntriesCount
337+ + " items for node " + node );
329338 return channelManager .countNodeItems (node );
330339 } finally {
331340 if (itemIt != null )
@@ -335,15 +344,13 @@ private int getNodeItems(Element items, int maxItemsToReturn,
335344
336345 private void addItemToResponse (NodeItem nodeItem , Element parent ) {
337346 try {
338- entry = xmlReader .read (
339- new StringReader (nodeItem .getPayload ()))
347+ entry = xmlReader .read (new StringReader (nodeItem .getPayload ()))
340348 .getRootElement ();
341349 Element item = parent .addElement ("item" );
342350 item .addAttribute ("id" , nodeItem .getId ());
343351 item .add (entry );
344352 } catch (DocumentException e ) {
345- logger .error ("Error parsing a node entry, ignoring. "
346- + nodeItem );
353+ logger .error ("Error parsing a node entry, ignoring. " + nodeItem );
347354 }
348355 }
349356
@@ -363,12 +370,12 @@ private int getSubscriptionItems(Element items, int maxItemsToReturn,
363370 Element query ;
364371
365372 for (NodeSubscription subscriber : subscribers ) {
366-
373+
367374 jidItem = items .addElement ("item" );
368375 jidItem .addAttribute ("id" , subscriber .getUser ().toString ());
369376 query = jidItem .addElement ("query" );
370377 query .addNamespace ("" , JabberPubsub .NS_DISCO_ITEMS );
371-
378+
372379 if (firstItem == null ) {
373380 firstItem = subscriber .getUser ().toString ();
374381 }
@@ -384,18 +391,19 @@ private void addSubscriptionItems(Element query, JID subscriber)
384391
385392 ResultSet <NodeSubscription > subscriptions = channelManager
386393 .getUserSubscriptions (subscriber );
387-
394+
388395 if ((null == subscriptions ) || (0 == subscriptions .size ())) {
389396 return ;
390397 }
391398 Element item ;
392399 Namespace ns1 = new Namespace ("ns1" , JabberPubsub .NAMESPACE_URI );
393400 Namespace ns2 = new Namespace ("ns2" , JabberPubsub .NAMESPACE_URI );
394- // TODO: This whole section of code is very inefficient
401+ // TODO: This whole section of code is very inefficient
395402 for (NodeSubscription subscription : subscriptions ) {
396- ////if (false == subscription.getNodeId().contains(fetchersJid.toBareJID())) {
397- // continue;
398- //}
403+ // //if (false ==
404+ // subscription.getNodeId().contains(fetchersJid.toBareJID())) {
405+ // continue;
406+ // }
399407 NodeAffiliation affiliation = channelManager .getUserAffiliation (
400408 subscription .getNodeId (), subscription .getUser ());
401409 item = query .addElement ("item" );
@@ -405,10 +413,10 @@ private void addSubscriptionItems(Element query, JID subscriber)
405413 item .addAttribute ("node" , subscription .getNodeId ());
406414 QName affiliationAttribute = new QName ("affiliation" , ns1 );
407415 QName subscriptionAttribute = new QName ("subscription" , ns2 );
408- item .addAttribute (affiliationAttribute , affiliation . getAffiliation ()
409- .toString ());
410- item .addAttribute (subscriptionAttribute , subscription . getSubscription ()
411- .toString ());
416+ item .addAttribute (affiliationAttribute , affiliation
417+ .getAffiliation (). toString ());
418+ item .addAttribute (subscriptionAttribute , subscription
419+ .getSubscription (). toString ());
412420 }
413421 }
414422
0 commit comments