Commit 72248555 authored by Holger Bergunde's avatar Holger Bergunde Committed by holger.bergunde

OF-570 GoJara removes contacts from roster if gateway registration gets deleted

git-svn-id: http://svn.igniterealtime.org/svn/repos/openfire/trunk@13296 b35dd754-fafc-0310-a699-88a17e54d16e
parent ddf4de9a
......@@ -44,6 +44,12 @@
GoJara Plugin Changelog
</h1>
<p><b>1.2.2 Alpha</b> -- Feb 17, 2012</p>
<ul>
<li>Fixed: Remove remote contacts from roster when deleting gateway registration [<a href="http://issues.igniterealtime.org/browse/OF-570">OF-570</a>]</li>
</ul>
<p><b>1.2 Alpha</b> -- Feb 17, 2012</p>
<ul>
......
......@@ -7,8 +7,8 @@
<name>GoJara</name>
<description>ProtoXEP-xxxx: Remote Roster Management support</description>
<author>Holger Bergunde and Daniel Henninger</author>
<version>1.2.1 Alpha</version>
<date>02/17/2012</date>
<version>1.2.2 Alpha</version>
<date>09/17/2012</date>
<databaseKey>gojara</databaseKey>
<databaseVersion>0</databaseVersion>
<minServerVersion>3.7.0</minServerVersion>
......
......@@ -102,6 +102,9 @@ public class RemoteRosterInterceptor implements PacketInterceptor {
* admin panel
*/
_packetProcessor.get("sparkIQRegistered").process(packet);
} else if (myPacket.getType().equals(IQ.Type.set) && myPacket.getTo().toString().equals(_mySubdomain)) {
System.out.println("war das ein remove an mich????");
_packetProcessor.get("handleCleanUp").process(packet);
}
}
// else if (packet instanceof Presence) {
......
......@@ -2,59 +2,64 @@ package org.jivesoftware.openfire.plugin.gojara.messagefilter.remoteroster.proce
import java.util.Collection;
import org.jivesoftware.openfire.SharedGroupException;
import org.jivesoftware.openfire.interceptor.PacketRejectedException;
import org.jivesoftware.openfire.plugin.gojara.messagefilter.remoteroster.RemoteRosterInterceptor;
import org.jivesoftware.openfire.roster.Roster;
import org.jivesoftware.openfire.roster.RosterItem;
import org.jivesoftware.openfire.roster.RosterManager;
import org.jivesoftware.openfire.user.UserNotFoundException;
import org.xmpp.packet.IQ;
import org.xmpp.packet.Packet;
import org.xmpp.packet.Presence;
/**
* This class is a part of the command pattern used in
* {@link RemoteRosterInterceptor}. If the remote contacts should not be saved
* permanently in the users roster this command will clean up the users roster.
* If the remote contact went offline it will get removed from user's roster.
*
* @author Holger Bergunde
* This class cleans up a roster from contacts if the user removes/deletes the
* gateway registration. After deleting a registration there should not be any
* gateway related contacts left
*
* @author holger.bergunde
*
*/
public class CleanUpRosterProcessor extends AbstractRemoteRosterProcessor {
private String _myDomain;
private RosterManager _rosterManager;
private String _subDomain;
public CleanUpRosterProcessor(RosterManager rostermananger, String subdomain) {
Log.debug("Createt CleanUpRosterProcessor for " + subdomain);
_rosterManager = rostermananger;
_subDomain = subdomain;
public CleanUpRosterProcessor(RosterManager rosterMananger, String mySubdomain) {
Log.debug("Created CleanUpRosterProcessor for " + mySubdomain);
_myDomain = mySubdomain;
_rosterManager = rosterMananger;
}
@Override
public void process(Packet packet) throws PacketRejectedException {
Log.debug("Processing packet in CleanUpRosterProcessor for " + _subDomain);
Presence myPacket = (Presence) packet;
String to = myPacket.getTo().toString();
String username = getUsernameFromJid(to);
if (myPacket.getType() != null && myPacket.getType().equals(Presence.Type.unavailable)) {
if (packet instanceof IQ) {
IQ iqPacket = (IQ) packet;
if (findNodesInDocument(iqPacket.getElement().getDocument(), "//register:remove").size() > 0) {
String username = getUsernameFromJid(packet.getFrom().toString());
Roster roster;
try {
Roster roster = _rosterManager.getRoster(username);
roster = _rosterManager.getRoster(username);
Collection<RosterItem> items = roster.getRosterItems();
for (RosterItem item : items) {
String itemName = item.getJid().toString();
if (itemName.contains(_subDomain) && !itemName.equals(_subDomain)) {
Log.debug("Removing contact " + item.getJid().toString() + " from contact list.");
if (itemName.contains(_myDomain) && !itemName.equals(_myDomain)) {
Log.debug("Removing contact " + username + " from contact list.");
roster.deleteRosterItem(item.getJid(), false);
}
}
} catch (Exception e) {
Log.debug("Execption occured when cleaning up the Roster.", e);
e.printStackTrace();
} catch (UserNotFoundException e) {
Log.debug("Could not found user while cleaning up the roster in GoJara for user " + username, e);
} catch (SharedGroupException e) {
// We should ignore this. External contacts cannot be in
// shared groups
}
}
}
}
}
\ No newline at end of file
......@@ -24,7 +24,7 @@ public class ClientToComponentUpdateProcessor extends AbstractRemoteRosterProces
private String _myDomain;
public ClientToComponentUpdateProcessor(String mySubdomain) {
Log.debug("Createt ClientToComponentUpdateProcessor for " + mySubdomain);
Log.debug("Created ClientToComponentUpdateProcessor for " + mySubdomain);
_myDomain = mySubdomain;
}
......
......@@ -32,7 +32,7 @@ public class DiscoIQResigteredProcessor extends AbstractRemoteRosterProcessor {
private String _mySubdoman;
public DiscoIQResigteredProcessor(String subdomain) {
Log.debug("Createt DiscoIQResigteredProcessor for " + subdomain);
Log.debug("Created DiscoIQResigteredProcessor for " + subdomain);
_mySubdoman = subdomain;
}
......
package org.jivesoftware.openfire.plugin.gojara.messagefilter.remoteroster.processors;
import java.util.Collection;
import org.jivesoftware.openfire.interceptor.PacketRejectedException;
import org.jivesoftware.openfire.plugin.gojara.messagefilter.remoteroster.RemoteRosterInterceptor;
import org.jivesoftware.openfire.roster.Roster;
import org.jivesoftware.openfire.roster.RosterItem;
import org.jivesoftware.openfire.roster.RosterManager;
import org.xmpp.packet.Packet;
import org.xmpp.packet.Presence;
/**
* This class is a part of the command pattern used in
* {@link RemoteRosterInterceptor}. If the remote contacts should not be saved
* permanently in the users roster this command will clean up the users roster.
* If the remote contact went offline it will get removed from user's roster.
*
* @author Holger Bergunde
*
*/
public class NonPersistantRosterProcessor extends AbstractRemoteRosterProcessor {
private RosterManager _rosterManager;
private String _subDomain;
public NonPersistantRosterProcessor(RosterManager rostermananger, String subdomain) {
Log.debug("Created CleanUpRosterProcessor for " + subdomain);
_rosterManager = rostermananger;
_subDomain = subdomain;
}
@Override
public void process(Packet packet) throws PacketRejectedException {
Log.debug("Processing packet in CleanUpRosterProcessor for " + _subDomain);
Presence myPacket = (Presence) packet;
String to = myPacket.getTo().toString();
String username = getUsernameFromJid(to);
if (myPacket.getType() != null && myPacket.getType().equals(Presence.Type.unavailable)) {
try {
Roster roster = _rosterManager.getRoster(username);
Collection<RosterItem> items = roster.getRosterItems();
for (RosterItem item : items) {
String itemName = item.getJid().toString();
if (itemName.contains(_subDomain) && !itemName.equals(_subDomain)) {
Log.debug("Removing contact " + item.getJid().toString() + " from contact list.");
roster.deleteRosterItem(item.getJid(), false);
}
}
} catch (Exception e) {
Log.debug("Execption occured when cleaning up the Roster.", e);
e.printStackTrace();
}
}
}
}
......@@ -34,7 +34,7 @@ public class ReceiveComponentUpdatesProcessor extends AbstractRemoteRosterProces
public ReceiveComponentUpdatesProcessor(RosterManager rosterManager, String subdomain) {
_mySubdomain = subdomain;
Log.debug("Createt ReceiveComponentUpdatesProcessor for " + _mySubdomain);
Log.debug("Created ReceiveComponentUpdatesProcessor for " + _mySubdomain);
_rosterManager = rosterManager;
}
......
......@@ -32,7 +32,7 @@ public class SendRosterProcessor extends AbstractRemoteRosterProcessor {
private String _componentName;
public SendRosterProcessor(RosterManager rosterMananger, String componentName) {
Log.debug("Createt SendRosterProcessor for " + componentName);
Log.debug("Created SendRosterProcessor for " + componentName);
_rosterManager = rosterMananger;
_componentName = componentName;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment