@SpecCompliance(compliant = {
@SpecCompliant(spec = "RFC3921bis-05", section = "3.1.2", status = IN_PROGRESS, comment = "current impl based hereupon"),
@SpecCompliant(spec = "RFC3921bis-08", section = "3.1.2", status = NOT_STARTED, comment = "major rephrasing from bis-05 not yet taken into account") })
protected void handleOutboundSubscriptionRequest(PresenceStanza stanza, ServerRuntimeContext serverRuntimeContext,
SessionContext sessionContext, ResourceRegistry registry, RosterManager rosterManager) {
StanzaRelay stanzaRelay = serverRuntimeContext.getStanzaRelay();
Entity user = stanza.getFrom();
Entity contact = stanza.getTo().getBareJID();
// TODO schedule a observer which can re-send the request
RosterItem rosterItem = null;
try {
rosterItem = getExistingOrNewRosterItem(rosterManager, user.getBareJID(), contact);
RosterSubscriptionMutator.Result result = RosterSubscriptionMutator.getInstance().add(rosterItem,
ASK_SUBSCRIBE);
if (result != OK) {
return;
}
rosterManager.addContact(user.getBareJID(), rosterItem);
} catch (RosterException e) {
throw new RuntimeException(e);
}
// relay the stanza to the contact (via the contact's server)
try {
stanzaRelay.relay(stanza.getTo(), stanza, new IgnoreFailureStrategy());
} catch (DeliveryException e) {
e.printStackTrace();
}
// send roster push to all of the user's interested resources