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

OF-490 added Log.debug() for debugging

git-svn-id: http://svn.igniterealtime.org/svn/repos/openfire/trunk@12901 b35dd754-fafc-0310-a699-88a17e54d16e
parent 31b70147
......@@ -6,9 +6,9 @@
<name>Remote Roster</name>
<description>ProtoXEP-xxxx: Remote Roster Management support</description>
<author>Daniel Henninger</author>
<version>1.0.0</version>
<date>10/16/2011</date>
<author>Holger Bergunde & Daniel Henninger</author>
<version>1.0.0 Alpha</version>
<date>12/01/2011</date>
<minServerVersion>3.7.0</minServerVersion>
<!-- Admin console entries -->
......
......@@ -21,17 +21,18 @@ import org.xmpp.packet.Packet;
public class RemotePackageInterceptor implements PacketInterceptor {
private static final Logger Log = LoggerFactory.getLogger(RemoteRosterPlugin.class);
private static final Logger Log = LoggerFactory.getLogger(RemotePackageInterceptor.class);
private String _mySubdomain;
private Map<String, AbstractRemoteRosterProcessor> _packetProcessor = new HashMap<String, AbstractRemoteRosterProcessor>();
public RemotePackageInterceptor(String initialSubdomain) {
Log.debug("Starting Package Interceptor for "+initialSubdomain);
_mySubdomain = initialSubdomain;
XMPPServer server = XMPPServer.getInstance();
RosterManager rosterMananger = server.getRosterManager();
AbstractRemoteRosterProcessor sendroster = new SendRosterProcessor(rosterMananger, _mySubdomain);
AbstractRemoteRosterProcessor receiveChanges = new ReceiveComponentUpdatesProcessor(rosterMananger);
AbstractRemoteRosterProcessor receiveChanges = new ReceiveComponentUpdatesProcessor(rosterMananger, _mySubdomain);
AbstractRemoteRosterProcessor iqRegistered = new DiscoIQResigteredProcessor(_mySubdomain);
AbstractRemoteRosterProcessor cleanUp = new CleanUpRosterProcessor(rosterMananger, _mySubdomain);
AbstractRemoteRosterProcessor updateToComponent = new ClientToComponentUpdateProcessor(_mySubdomain);
......@@ -48,6 +49,7 @@ public class RemotePackageInterceptor implements PacketInterceptor {
{
if (!processed && incoming) {
if (packet instanceof IQ) {
Log.debug("Incomping unprocessed package i might be interested in. Package: \n"+packet.toString()+"\n");
IQ myPacket = (IQ) packet;
if (myPacket.getFrom() == null || myPacket.getTo() == null) {
/*
......@@ -63,6 +65,7 @@ public class RemotePackageInterceptor implements PacketInterceptor {
}
return;
}
@SuppressWarnings("unused")
String to = myPacket.getTo().toString();
String from = myPacket.getFrom().toString();
......
......@@ -20,12 +20,14 @@ import org.jivesoftware.openfire.session.ComponentSession;
import org.jivesoftware.util.JiveGlobals;
import org.jivesoftware.util.PropertyEventDispatcher;
import org.jivesoftware.util.PropertyEventListener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.xmpp.packet.IQ;
import org.xmpp.packet.JID;
public class RemoteRosterPlugin implements Plugin {
// private static final Logger Log = LoggerFactory.getLogger(RemoteRosterPlugin.class);
private static final Logger Log = LoggerFactory.getLogger(RemoteRosterPlugin.class);
final SessionManager _sessionManager = SessionManager.getInstance();
private Map<String, RemotePackageInterceptor> _interceptors = new HashMap<String, RemotePackageInterceptor>();
private static PluginManager pluginManager;
......@@ -40,6 +42,7 @@ public class RemoteRosterPlugin implements Plugin {
public void initializePlugin(PluginManager manager, File pluginDirectory)
{
Log.debug("Starting RemoteRoster Plguin");
pluginManager = manager;
manageExternalComponents();
listenToSettings();
......@@ -127,6 +130,7 @@ public class RemoteRosterPlugin implements Plugin {
private void updateInterceptors(String componentJID)
{
Log.debug("Updating my package interceptors for component "+componentJID);
boolean allowed = JiveGlobals.getBooleanProperty("plugin.remoteroster.jids."+componentJID, false);
if (allowed)
{
......@@ -158,6 +162,7 @@ public class RemoteRosterPlugin implements Plugin {
{
RemotePackageInterceptor interceptor = _interceptors.get(initialSubdomain);
if (interceptor != null) {
Log.debug("Removing package interceptor for "+initialSubdomain);
_interceptorManager.removeInterceptor(interceptor);
_interceptors.remove(initialSubdomain);
}
......@@ -165,6 +170,7 @@ public class RemoteRosterPlugin implements Plugin {
private void createNewPackageIntercetor(String initialSubdomain)
{
Log.debug("Creating package interceptor.");
RemotePackageInterceptor interceptor = new RemotePackageInterceptor(initialSubdomain);
_interceptors.put(initialSubdomain, interceptor);
_interceptorManager.addInterceptor(interceptor);
......
......@@ -8,10 +8,13 @@ import org.jivesoftware.openfire.PacketRouter;
import org.jivesoftware.openfire.XMPPServer;
import org.jivesoftware.openfire.interceptor.PacketRejectedException;
import org.jivesoftware.openfire.plugin.Utils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.xmpp.packet.Packet;
abstract public class AbstractRemoteRosterProcessor {
protected static final Logger Log = LoggerFactory.getLogger(AbstractRemoteRosterProcessor.class);
XMPPServer _server;
PacketRouter _router;
......@@ -24,6 +27,7 @@ abstract public class AbstractRemoteRosterProcessor {
protected void dispatchPacket(Packet packet)
{
Log.debug("Sending package to PacketRouter: \n"+packet.toString()+"\n");
PacketRouter router = _server.getPacketRouter();
router.route(packet);
}
......
......@@ -11,11 +11,11 @@ import org.xmpp.packet.Presence;
public class CleanUpRosterProcessor extends AbstractRemoteRosterProcessor {
private RosterManager _rosterManager;
private String _subDomain;
public CleanUpRosterProcessor(RosterManager rostermananger, String subdomain) {
Log.debug("Createt CleanUpRosterProcessor for "+subdomain);
_rosterManager = rostermananger;
_subDomain = subdomain;
}
......@@ -23,43 +23,28 @@ public class CleanUpRosterProcessor extends AbstractRemoteRosterProcessor {
@Override
public void process(Packet packet) throws PacketRejectedException
{
// System.out.println("hab hier was ne oder was");
Log.debug("Processing packet in CleanUpRosterProcessor for "+_subDomain);
Presence myPacket = (Presence) packet;
String to = myPacket.getTo().toString();
String username = getUsernameFromJid(to);
//<presence id="19nTS-48" to="xmpp.dew08299" type="unavailable"/
if (myPacket.getType() != null && myPacket.getType().equals(Presence.Type.unavailable))
{
System.out.println("is unavaibale ------------");
if (myPacket.getType() != null && myPacket.getType().equals(Presence.Type.unavailable)) {
try {
Roster roster = _rosterManager.getRoster(username);
Collection <RosterItem> items = roster.getRosterItems();
Collection<RosterItem> items = roster.getRosterItems();
for (RosterItem item: items)
{
for (RosterItem item : items) {
String itemName = item.getJid().toString();
System.out.println("NAME: "+itemName+ " sub: "+_subDomain);
if (itemName.contains(_subDomain) && !itemName.equals(_subDomain))
{
System.out.println("entferne "+itemName);
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) {
System.out.println("hier lief was falsch");
Log.debug("Execption occured when cleaning up the Roster.",e);
e.printStackTrace();
}
}
}
......
......@@ -9,14 +9,15 @@ import org.xmpp.packet.Packet;
public class ClientToComponentUpdateProcessor extends AbstractRemoteRosterProcessor {
private String _myDomain;
public ClientToComponentUpdateProcessor(String mySubdomain) {
Log.debug("Createt ClientToComponentUpdateProcessor for "+mySubdomain);
_myDomain = mySubdomain;
}
@Override
public void process(Packet packet) throws PacketRejectedException
{
Log.debug("Processing packet in ClientToComponentUpdateProcessor for "+_myDomain);
Element query = ((IQ) packet).getChildElement();
if (query != null && query.getNamespaceURI().equals("jabber:iq:roster")) {
if (findNodesInDocument(query.getDocument(), "//roster:item").size() > 0) {
......@@ -26,6 +27,7 @@ public class ClientToComponentUpdateProcessor extends AbstractRemoteRosterProces
// conflicts
// when we remove our legacy network registration.
if (jid.contains("@" + _myDomain) && !n.valueOf("@subscription").equals("remove")) {
Log.debug("Mirroring packet from local network to legacy component "+_myDomain);
IQ forward = (IQ) packet.createCopy();
forward.setTo(_myDomain);
dispatchPacket(forward);
......
......@@ -21,16 +21,18 @@ public class DiscoIQResigteredProcessor extends AbstractRemoteRosterProcessor {
private String _mySubdoman;
public DiscoIQResigteredProcessor(String subdomain) {
Log.debug("Createt DiscoIQResigteredProcessor for " + subdomain);
_mySubdoman = subdomain;
}
@Override
public void process(Packet packet) throws PacketRejectedException
{
//Check if the jabber:iq:register is enabled in admin panel
Log.debug("Processing packet in DiscoIQResigteredProcessor for "+_mySubdoman);
// Check if the jabber:iq:register is enabled in admin panel
boolean isFeatureEnabled = JiveGlobals.getBooleanProperty("plugin.remoteroster.sparkDiscoInfo", false);
if (!isFeatureEnabled)
{
if (!isFeatureEnabled) {
Log.debug("Spark extension is deactivated. Won't change the disco#info");
return;
}
......@@ -39,7 +41,6 @@ public class DiscoIQResigteredProcessor extends AbstractRemoteRosterProcessor {
final InterceptorManager interceptorManager = InterceptorManager.getInstance();
final PacketInterceptor interceptor = new PacketInterceptor() {
@Override
public void interceptPacket(Packet packet, Session session, boolean incoming, boolean processed)
throws PacketRejectedException
......@@ -60,11 +61,13 @@ public class DiscoIQResigteredProcessor extends AbstractRemoteRosterProcessor {
&& ns.equals("http://jabber.org/protocol/disco#info")
&& iqPacket.getFrom().toString().equals(_mySubdoman)) {
// This is the answer of the disco#info from spark
// to our component.
// add the jabber:iq:register feature if we are
// registered
/*
* This is the answer of the disco#info from spark
* to our component. add the jabber:iq:register
* feature if we are registered
*/
if (isRegistered()) {
Log.debug("Modifying disco#info packge to send registered iq feature to Spark user "+iqPacket.getTo().toString());
Attribute attribut = new DefaultAttribute("var", "jabber:iq:registered");
iqPacket.getChildElement().addElement("feature").add(attribut);
}
......@@ -74,6 +77,7 @@ public class DiscoIQResigteredProcessor extends AbstractRemoteRosterProcessor {
}
};
Log.debug("Creating my own listener for jabber:iq:register result to external component "+_mySubdoman);
interceptorManager.addInterceptor(interceptor);
IQ askComponent = new IQ();
......@@ -84,13 +88,13 @@ public class DiscoIQResigteredProcessor extends AbstractRemoteRosterProcessor {
query.addNamespace("", "jabber:iq:register");
askComponent.setChildElement(query);
//Remove the package intercepter in 1sec
// Remove the package intercepter in 1sec
TimerTask removeInterceptorTask = new TimerTask() {
@Override
public void run()
{
Log.debug("Removing my created listener for jabber:iq:register. Component "+_mySubdoman);
interceptorManager.removeInterceptor(interceptor);
}
};
......@@ -98,7 +102,7 @@ public class DiscoIQResigteredProcessor extends AbstractRemoteRosterProcessor {
Timer timer = new Timer();
timer.schedule(removeInterceptorTask, 1000);
//Send the register query to component
// Send the register query to component
dispatchPacket(askComponent);
}
......
......@@ -16,15 +16,18 @@ import org.xmpp.packet.Packet;
public class ReceiveComponentUpdatesProcessor extends AbstractRemoteRosterProcessor{
private RosterManager _rosterManager;
private String _mySubdomain;
public ReceiveComponentUpdatesProcessor(RosterManager rosterManager) {
public ReceiveComponentUpdatesProcessor(RosterManager rosterManager, String subdomain) {
_mySubdomain = subdomain;
Log.debug("Createt ReceiveComponentUpdatesProcessor for "+_mySubdomain);
_rosterManager = rosterManager;
}
@Override
public void process(Packet packet) throws PacketRejectedException
{
Log.debug("Processing packet in ClientToComponentUpdateProcessor for "+_mySubdomain);
IQ myPacket = (IQ) packet;
String to = myPacket.getTo().toString();
String username = getUsernameFromJid(to);
......@@ -49,14 +52,13 @@ public class ReceiveComponentUpdatesProcessor extends AbstractRemoteRosterProces
grouplist.add(groupName);
}
boolean rosterPersisten = JiveGlobals.getBooleanProperty("plugin.remoteroster.persistent", true);
// System.out.println("fge item hinzu: "+jid+" mit gruppen: "+grouplist.toString());
Log.debug("Adding user "+jid+" to roster "+ to);
RosterItem item = roster.createRosterItem(new JID(jid), name, grouplist, false, rosterPersisten);
//RosterItem getThat = roster.getRosterItem(new JID(jid));
item.setSubStatus(RosterItem.SUB_BOTH);
roster.updateRosterItem(item);
} catch (Exception e) {
Log.debug("Could not add user to Roster "+username,e);
e.printStackTrace();
System.out.println("Exception beim hinzufuegen eines Konaktes!");
}
}
}
......
......@@ -19,6 +19,7 @@ public class SendRosterProcessor extends AbstractRemoteRosterProcessor {
private String _componentName;
public SendRosterProcessor(RosterManager rosterMananger, String componentName) {
Log.debug("Createt SendRosterProcessor for "+componentName);
_rosterManager = rosterMananger;
_componentName = componentName;
}
......@@ -26,10 +27,11 @@ public class SendRosterProcessor extends AbstractRemoteRosterProcessor {
@Override
public void process(Packet packet) throws PacketRejectedException
{
Log.debug("Processing packet in SendRosterProcessor for "+_componentName);
IQ myPacket = (IQ) packet;
String to = myPacket.getFrom().toString();
String username = getUsernameFromJid(to);
String from = myPacket.getFrom().toString();
String username = getUsernameFromJid(from);
Roster roster;
try {
......@@ -43,13 +45,14 @@ public class SendRosterProcessor extends AbstractRemoteRosterProcessor {
private void sendRosterToComponent(Packet requestPacket, Collection<RosterItem> items)
{
Log.debug("Sending contacts from user "+requestPacket.getFrom().toString()+" to external Component");
IQ iq = (IQ) requestPacket;
IQ response = IQ.createResultIQ(iq);
response.setTo(_componentName);
Element query = new DefaultElement("query");
for (RosterItem i : items) {
if (i.getJid().toString().contains(_componentName)) {
System.out.println("roster exchange: habe: "+i.getJid().toString());
Log.debug("Roster exchange for external component "+_componentName+". Sending user "+i.getJid().toString());
Element item = new DefaultElement("item");
item.add(new DefaultAttribute("jid", i.getJid().toString()));
item.add(new DefaultAttribute("name", i.getNickname()));
......@@ -64,7 +67,6 @@ public class SendRosterProcessor extends AbstractRemoteRosterProcessor {
}
query.addNamespace("", "jabber:iq:roster");
response.setChildElement(query);
System.out.println("sende response: "+response.toString());
dispatchPacket(response);
}
......
......@@ -14,7 +14,8 @@
webManager.init(request, response, session, application, out);
boolean save = request.getParameter("save") != null;
boolean success = request.getParameter("success") != null;
boolean persistentRoster = ParamUtils.getBooleanAttribute(request, "persistentEnabled");
//boolean persistentRoster = ParamUtils.getBooleanAttribute(request, "persistentEnabled");
boolean persistentRoster = true;
String sparkdiscoParam = request.getParameter("sparkDiscoInfo");
boolean sparkDiscoInfo = sparkdiscoParam == null? false: sparkdiscoParam.equals("true");
String[] componentsEnabled = request.getParameterValues("enabledComponents[]");
......@@ -121,6 +122,7 @@
}
%>
</div>
<!-- DISABLED PERSISTENT ROSTER UNTIL SPECTRUM SUPPORTS IT
<div class="jive-contentBoxHeader">Options</div>
<div class="jive-contentBox">
......@@ -153,7 +155,7 @@
</table>
</div>
-->
<div class="jive-contentBoxHeader">Client specific options</div>
<div class="jive-contentBox">
......
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