Skip to content

Commit 1efae9a

Browse files
author
Simon Tennant
committed
Merge pull request #299 from lloydwatkin/issues/294
Added additional logging
2 parents 232c861 + 5a17661 commit 1efae9a

File tree

3 files changed

+48
-5
lines changed

3 files changed

+48
-5
lines changed

src/main/java/org/buddycloud/channelserver/packetprocessor/iq/namespace/pubsub/set/ItemDelete.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import org.buddycloud.channelserver.pubsub.model.impl.GlobalItemIDImpl;
1818
import org.buddycloud.channelserver.pubsub.subscription.Subscriptions;
1919
import org.buddycloud.channelserver.utils.XMLConstants;
20+
import org.buddycloud.channelserver.utils.node.item.payload.Buddycloud;
2021
import org.dom4j.Element;
2122
import org.dom4j.Namespace;
2223
import org.dom4j.dom.DOMElement;
@@ -82,7 +83,10 @@ public void process(Element elm, JID actor, IQ reqIQ, Element rsm) throws Interr
8283
setErrorCondition(PacketError.Type.modify, PacketError.Condition.bad_request);
8384
} catch (IllegalArgumentException e) {
8485
LOGGER.error(e);
85-
setErrorCondition(PacketError.Type.modify, PacketError.Condition.bad_request);
86+
createExtendedErrorReply(
87+
PacketError.Type.modify, PacketError.Condition.bad_request,
88+
"global-id-error", Buddycloud.NS_ERROR, e.getMessage()
89+
);
8690
}
8791
outQueue.put(response);
8892
}

src/test/java/org/buddycloud/channelserver/packetprocessor/iq/namespace/pubsub/set/ItemDeleteTest.java

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -181,16 +181,17 @@ public void testProvidingEmptyItemIdReturnsError() throws Exception {
181181
}
182182

183183
@Test
184-
public void testItemWhichDoesntExistReturnsItemNotFoundError()
184+
public void itemWhichDoesntExistReturnsItemNotFoundError()
185185
throws Exception {
186+
186187
Mockito.when(channelManager.nodeExists(node)).thenReturn(true);
187188
Mockito.when(channelManager.getNodeItem(node, "item-id")).thenReturn(
188189
null);
189190
itemDelete.setChannelManager(channelManager);
190191

191192
itemDelete.process(element, jid, request, null);
192193

193-
Packet response = queue.poll(100, TimeUnit.MILLISECONDS);
194+
Packet response = queue.poll();
194195

195196
PacketError error = response.getError();
196197
Assert.assertNotNull(error);
@@ -285,12 +286,12 @@ public void testSuccessfulRequestSendsResponseStanza() throws Exception {
285286
itemDelete.process(element, jid, request, null);
286287

287288
Mockito.verify(channelManager).deleteNodeItemById(node, "item-id");
288-
IQ response = (IQ) queue.poll(100, TimeUnit.MILLISECONDS);
289+
IQ response = (IQ) queue.poll();
289290

290291
Assert.assertEquals(IQ.Type.result.toString(), response.getElement()
291292
.attribute("type").getValue());
292293
// Check that no notifications are sent
293-
Packet notification = queue.poll(100, TimeUnit.MILLISECONDS);
294+
Packet notification = queue.poll();
294295
Assert.assertNull(notification);
295296
}
296297

@@ -485,4 +486,32 @@ public void requestsThreadWhenDeletingParentPost() throws Exception {
485486
notification.getElement().element("event").element("items")
486487
.element("retract").attributeValue("id"));
487488
}
489+
490+
@Test
491+
public void canDeleteItemUsingAFullItemId() throws Exception {
492+
493+
NodeItem nodeItem = new NodeItemImpl(node, "item-id", new Date(),
494+
payload.replaceAll("[email protected]",
495+
"[email protected]"), "item-id");
496+
497+
Mockito.when(channelManager.nodeExists(node)).thenReturn(true);
498+
Mockito.when(
499+
channelManager.getNodeItem(Mockito.eq("/user/[email protected]/posts"),
500+
Mockito.eq("item-id"))).thenReturn(nodeItem);
501+
502+
IQ request = toIq(readStanzaAsString("/iq/pubsub/item/delete/request-full-id.stanza"));
503+
504+
itemDelete.setChannelManager(channelManager);
505+
506+
itemDelete.process(element, jid, request, null);
507+
508+
Mockito.verify(channelManager).deleteNodeItemById(node, "item-id");
509+
IQ response = (IQ) queue.poll();
510+
511+
Assert.assertEquals(IQ.Type.result.toString(), response.getElement()
512+
.attribute("type").getValue());
513+
// Check that no notifications are sent
514+
Packet notification = queue.poll();
515+
Assert.assertNull(notification);
516+
}
488517
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<iq type='set'
2+
from='[email protected]/thebalcony'
3+
to='channels.shakespeare.lit'
4+
id='retract1'>
5+
<pubsub xmlns='http://jabber.org/protocol/pubsub'>
6+
<retract node='/user/[email protected]/posts'>
7+
<item id='tag:[email protected],/user/[email protected]/posts,item-id' notify='true' />
8+
</retract>
9+
</pubsub>
10+
</iq>

0 commit comments

Comments
 (0)