Commit 949ccaef authored by Daniel Henninger's avatar Daniel Henninger Committed by dhenninger

Put back Serialization that's apparantly needed. Fixed typo in mysql db...

Put back Serialization that's apparantly needed.  Fixed typo in mysql db script.  Switched TEXT to VARCHAR(1024) because TEXT doesn't want to be an index.  Fixed up localization and logging.

git-svn-id: http://svn.igniterealtime.org/svn/repos/wildfire/trunk/src/plugins/gateway@4481 b35dd754-fafc-0310-a699-88a17e54d16e
parent 10748bed
CREATE TABLE gatewayRegistration (
regisrationID BIGINT NOT NULL,
jid TEXT NOT NULL,
registrationID BIGINT NOT NULL,
jid VARCHAR(1024) NOT NULL,
gatewayType VARCHAR(15) NOT NULL,
username VARCHAR(255) NOT NULL,
password VARCHAR(255),
......@@ -11,4 +11,4 @@ CREATE TABLE gatewayRegistration (
INDEX gatewayReg_type_idx(gatewayType)
);
INSERT INTO jiveVersion (name, version) VALUES ('gateway', 0);
\ No newline at end of file
INSERT INTO jiveVersion (name, version) VALUES ('gateway', 0);
......@@ -14,8 +14,6 @@ import java.util.*;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;
......@@ -26,6 +24,7 @@ import org.jivesoftware.wildfire.gateway.roster.PersistenceManager;
import org.jivesoftware.wildfire.gateway.roster.Roster;
import org.jivesoftware.wildfire.gateway.roster.Status;
import org.jivesoftware.wildfire.gateway.util.BackgroundThreadFactory;
import org.jivesoftware.util.Log;
import org.jivesoftware.util.LocaleUtils;
import org.xmpp.component.Component;
import org.xmpp.component.ComponentException;
......@@ -68,7 +67,7 @@ public abstract class BaseGateway implements Gateway, Component, Runnable {
*/
public final String getDomain() {
String domainName = this.componentManager.getServerName();
logger.log(Level.FINE, "basegateway.domainname", domainName);
Log.debug(LocaleUtils.getLocalizedString("basegateway.domainname", "gateway", Arrays.asList(domainName)));
return domainName;
}
......@@ -84,9 +83,6 @@ public abstract class BaseGateway implements Gateway, Component, Runnable {
return "gateway";
}
/** The logger. @see java.util.logging.Logger */
private static final Logger logger = Logger.getLogger("BaseGateway","gateway_i18n");
/**
* Jabber endpoint.
*/
......@@ -186,7 +182,7 @@ public abstract class BaseGateway implements Gateway, Component, Runnable {
reply.setChildElement(responseElement);
}
catch (Exception e) {
logger.log(Level.WARNING, "basegateway.notfound", iq.getFrom().toBareJID());
Log.warn(LocaleUtils.getLocalizedString("basegateway.notfound", "gateway", Arrays.asList(iq.getFrom().toBareJID())));
}
return reply;
}
......@@ -260,7 +256,7 @@ public abstract class BaseGateway implements Gateway, Component, Runnable {
results.add(unsubscribed);
results.add(unavailable);
logger.log(Level.INFO, "basegateway.unregister", iq.getFrom());
Log.info(LocaleUtils.getLocalizedString("basegateway.unregister", "gateway", Arrays.asList(iq.getFrom())));
return results;
}
......@@ -302,7 +298,7 @@ public abstract class BaseGateway implements Gateway, Component, Runnable {
}
catch (Exception e) {
// unable to use dataform
logger.log(Level.FINER, "basegateway.dataformnotused", e);
Log.debug(LocaleUtils.getLocalizedString("basegateway.dataformnotused", "gateway"), e);
}
if (username == null || password == null) {
......@@ -326,7 +322,7 @@ public abstract class BaseGateway implements Gateway, Component, Runnable {
response.add(result);
}
else {
logger.log(Level.INFO, "basegateway.register", username.trim());
Log.info(LocaleUtils.getLocalizedString("basegateway.register", "gateway", Arrays.asList(username.trim())));
SubscriptionInfo info = new SubscriptionInfo(username.trim(), password);
PersistenceManager.Factory.get(this).getRegistrar().add(iq.getFrom(), info);
reply.setChildElement(responseElement);
......@@ -390,7 +386,7 @@ public abstract class BaseGateway implements Gateway, Component, Runnable {
responseElement.add(item);
}
reply.setChildElement(responseElement);
System.out.println(reply);
Log.debug(reply.toString());
return reply;
}
......@@ -448,7 +444,7 @@ public abstract class BaseGateway implements Gateway, Component, Runnable {
processPacket((Message)packet);
}
else {
System.out.println("UNHANDLED: " + packet.toString());
Log.debug("UNHANDLED: " + packet.toString());
}
// process
......@@ -458,7 +454,7 @@ public abstract class BaseGateway implements Gateway, Component, Runnable {
}
}
else {
//System.out.println("Request[" + packet.toString() + "] with no response");
//Log.debug("Request[" + packet.toString() + "] with no response");
}
}
......@@ -476,7 +472,7 @@ public abstract class BaseGateway implements Gateway, Component, Runnable {
* @see org.xmpp.packet.Message
*/
private void processPacket(Message message) throws Exception {
logger.finer(message.toString());
Log.debug(message.toString());
GatewaySession session = PersistenceManager.Factory.get(this).getRegistrar().getGatewaySession(message.getFrom());
session.getLegacyEndpoint().sendPacket(message);
......@@ -493,16 +489,16 @@ public abstract class BaseGateway implements Gateway, Component, Runnable {
List<Presence> p = new ArrayList<Presence>();
JID from = presence.getFrom();
logger.finest(presence.toString());
Log.debug(presence.toString());
/*
* Unknown entity is trying to access the gateway.
*/
if (!rosterManager.getRegistrar().isRegistered(NormalizedJID.wrap(from))) {
logger.log(Level.INFO, "basegateway.unabletofind", from);
Log.info(LocaleUtils.getLocalizedString("basegateway.unabletofind", "gateway", Arrays.asList(from)));
// silently ignore a delete request
if (!Presence.Type.unavailable.equals(presence.getType())) {
logger.log(Level.INFO, "basegateway.unauthorizedrequest", new Object[] { presence.getType(), from.toString() });
Log.info(LocaleUtils.getLocalizedString("basegateway.unauthorizedrequest", "gateway", Arrays.asList(new Object[] { presence.getType(), from.toString() })));
Presence result = new Presence();
result.setError(Condition.not_authorized);
result.setStatus(LocaleUtils.getLocalizedString("basegateway.registerfirst", "gateway"));
......@@ -516,7 +512,7 @@ public abstract class BaseGateway implements Gateway, Component, Runnable {
*/
GatewaySession sessionInfo = rosterManager.getRegistrar().getGatewaySession(from);
if (sessionInfo == null) {
logger.log(Level.WARNING, "basegateway.unabletolocatesession" , from);
Log.warn(LocaleUtils.getLocalizedString("basegateway.unabletolocatesession" , "gateway", Arrays.asList(from)));
return p;
}
......@@ -541,7 +537,7 @@ public abstract class BaseGateway implements Gateway, Component, Runnable {
sessionInfo.getSubscriptionInfo().clientRegistered = true;
}
else { // subscribe to legacy user
logger.log(Level.FINE,"basegateway.subscribed");
Log.debug(LocaleUtils.getLocalizedString("basegateway.subscribed", "gateway"));
}
}
else if (Presence.Type.unavailable.equals(presence.getType())){
......@@ -563,7 +559,7 @@ public abstract class BaseGateway implements Gateway, Component, Runnable {
result.setTo(presence.getFrom());
result.setFrom(this.jid);
p.add(result);
logger.log(Level.FINE, "basegateway.gatewaypresence");
Log.debug(LocaleUtils.getLocalizedString("basegateway.gatewaypresence", "gateway"));
}
else {
GatewaySession session = rosterManager.getRegistrar().getGatewaySession(presence.getFrom());
......@@ -583,8 +579,7 @@ public abstract class BaseGateway implements Gateway, Component, Runnable {
p.add(p2);
}
catch (Exception e) {
logger.log(Level.WARNING, "basegateway.statusexception",
new Object[]{presence.getTo(), presence.getFrom(), e.getLocalizedMessage()});
Log.warn(LocaleUtils.getLocalizedString("basegateway.statusexception", "gateway", Arrays.asList(new Object[]{presence.getTo(), presence.getFrom(), e.getLocalizedMessage()})));
}
}
return p;
......@@ -657,7 +652,7 @@ public abstract class BaseGateway implements Gateway, Component, Runnable {
* subscribed the contact to the JID.
*/
public void run() {
logger.log(Level.FINEST, "basegateway.maintenancestart");
Log.debug(LocaleUtils.getLocalizedString("basegateway.maintenancestart", "gateway"));
for (SubscriptionInfo si : rosterManager.getRegistrar().getAllGatewaySessions()) {
if (!si.clientRegistered) {
......@@ -682,7 +677,7 @@ public abstract class BaseGateway implements Gateway, Component, Runnable {
// try {
// componentManager.sendPacket(this, p);
// } catch (Exception e) {
// logger.log(Level.WARNING, "basegateway.unabletosendpresence", e);
// Log.warn(LocaleUtils.getLocalizedString("basegateway.unabletosendpresence", "gateway"), e);
// }
// }
}
......@@ -695,11 +690,11 @@ public abstract class BaseGateway implements Gateway, Component, Runnable {
// try {
// componentManager.sendPacket(this, p);
// } catch (Exception e) {
// logger.log(Level.WARNING, "basegateway.unabletosendpresence", e);
// Log.warn(LocaleUtils.getLocalizedString("basegateway.unabletosendpresence", "gateway"), e);
// }
// }
logger.log(Level.FINEST, "basegateway.maintenancestop");
Log.debug(LocaleUtils.getLocalizedString("basegateway.maintenancestop", "gateway"));
}
/**
......
......@@ -11,14 +11,17 @@
package org.jivesoftware.wildfire.gateway;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.jivesoftware.util.Log;
import org.jivesoftware.util.LocaleUtils;
import org.xmpp.component.Component;
import org.xmpp.component.ComponentException;
import org.xmpp.component.ComponentManager;
import org.xmpp.packet.Packet;
import java.util.Arrays;
/**
* The <code>JabberEndpoint</code> implements the <code>Endpoint</code> for an
* XMPP server.
......@@ -83,16 +86,13 @@ public class JabberEndpoint implements Endpoint {
}
else {
queue.add(packet);
logger.log(Level.FINE, "jabberendpoint.sendpacketenqueue", packet.getFrom());
Log.debug(LocaleUtils.getLocalizedString("jabberendpoint.sendpacketenqueue", "gateway", Arrays.asList(packet.getFrom())));
}
}
/** The backlog queue. */
private final ConcurrentLinkedQueue<Packet> queue = new ConcurrentLinkedQueue<Packet>();
/** The logger. */
final static private Logger logger = Logger.getLogger("JabberEndpoint", "gateway_i18n");
/**
* @see org.jivesoftware.wildfire.gateway.Endpoint#getValve()
*/
......
......@@ -10,7 +10,7 @@
package org.jivesoftware.wildfire.gateway.protocols.yahoo;
import java.util.logging.Logger;
import org.jivesoftware.util.Log;
import ymsg.network.event.SessionChatEvent;
import ymsg.network.event.SessionConferenceEvent;
......@@ -32,56 +32,53 @@ import ymsg.network.event.SessionNotifyEvent;
*/
public class NoopSessionListener implements SessionListener {
/** The logger. @see java.util.logging.Logger */
private static final Logger logger = Logger.getLogger("NoopSessionListener");
/**
* @see ymsg.network.event.SessionListener#fileTransferReceived(ymsg.network.event.SessionFileTransferEvent)
*/
public void fileTransferReceived(SessionFileTransferEvent arg0) {
logger.info(arg0.toString());
Log.info(arg0.toString());
}
/**
* @see ymsg.network.event.SessionListener#connectionClosed(ymsg.network.event.SessionEvent)
*/
public void connectionClosed(SessionEvent arg0) {
logger.info(arg0.toString());
Log.info(arg0.toString());
}
/**
* @see ymsg.network.event.SessionListener#listReceived(ymsg.network.event.SessionEvent)
*/
public void listReceived(SessionEvent arg0) {
logger.info(arg0.toString());
Log.info(arg0.toString());
}
/**
* @see ymsg.network.event.SessionListener#messageReceived(ymsg.network.event.SessionEvent)
*/
public void messageReceived(SessionEvent arg0) {
logger.finest(arg0.toString());
Log.debug(arg0.toString());
}
/**
* @see ymsg.network.event.SessionListener#buzzReceived(ymsg.network.event.SessionEvent)
*/
public void buzzReceived(SessionEvent arg0) {
logger.finest(arg0.toString());
Log.debug(arg0.toString());
}
/**
* @see ymsg.network.event.SessionListener#offlineMessageReceived(ymsg.network.event.SessionEvent)
*/
public void offlineMessageReceived(SessionEvent arg0) {
logger.finest(arg0.toString());
Log.debug(arg0.toString());
}
/**
* @see ymsg.network.event.SessionListener#errorPacketReceived(ymsg.network.event.SessionErrorEvent)
*/
public void errorPacketReceived(SessionErrorEvent arg0) {
logger.severe(arg0.toString());
Log.error(arg0.toString());
}
/**
......@@ -89,126 +86,126 @@ public class NoopSessionListener implements SessionListener {
*/
public void inputExceptionThrown(SessionExceptionEvent arg0) {
arg0.getException().printStackTrace();
logger.severe(arg0.toString());
Log.error(arg0.toString());
}
/**
* @see ymsg.network.event.SessionListener#newMailReceived(ymsg.network.event.SessionNewMailEvent)
*/
public void newMailReceived(SessionNewMailEvent arg0) {
logger.finest(arg0.toString());
Log.debug(arg0.toString());
}
/**
* @see ymsg.network.event.SessionListener#notifyReceived(ymsg.network.event.SessionNotifyEvent)
*/
public void notifyReceived(SessionNotifyEvent arg0) {
logger.finest(arg0.toString());
Log.debug(arg0.toString());
}
/**
* @see ymsg.network.event.SessionListener#contactRequestReceived(ymsg.network.event.SessionEvent)
*/
public void contactRequestReceived(SessionEvent arg0) {
logger.finest(arg0.toString());
Log.debug(arg0.toString());
}
/**
* @see ymsg.network.event.SessionListener#contactRejectionReceived(ymsg.network.event.SessionEvent)
*/
public void contactRejectionReceived(SessionEvent arg0) {
logger.finest(arg0.toString());
Log.debug(arg0.toString());
}
/**
* @see ymsg.network.event.SessionListener#conferenceInviteReceived(ymsg.network.event.SessionConferenceEvent)
*/
public void conferenceInviteReceived(SessionConferenceEvent arg0) {
logger.finest(arg0.toString());
Log.debug(arg0.toString());
}
/**
* @see ymsg.network.event.SessionListener#conferenceInviteDeclinedReceived(ymsg.network.event.SessionConferenceEvent)
*/
public void conferenceInviteDeclinedReceived(SessionConferenceEvent arg0) {
logger.finest(arg0.toString());
Log.debug(arg0.toString());
}
/**
* @see ymsg.network.event.SessionListener#conferenceLogonReceived(ymsg.network.event.SessionConferenceEvent)
*/
public void conferenceLogonReceived(SessionConferenceEvent arg0) {
logger.finest(arg0.toString());
Log.debug(arg0.toString());
}
/**
* @see ymsg.network.event.SessionListener#conferenceLogoffReceived(ymsg.network.event.SessionConferenceEvent)
*/
public void conferenceLogoffReceived(SessionConferenceEvent arg0) {
logger.finest(arg0.toString());
Log.debug(arg0.toString());
}
/**
* @see ymsg.network.event.SessionListener#conferenceMessageReceived(ymsg.network.event.SessionConferenceEvent)
*/
public void conferenceMessageReceived(SessionConferenceEvent arg0) {
logger.finest(arg0.toString());
Log.debug(arg0.toString());
}
/**
* @see ymsg.network.event.SessionListener#friendsUpdateReceived(ymsg.network.event.SessionFriendEvent)
*/
public void friendsUpdateReceived(SessionFriendEvent arg0) {
logger.finest(arg0.toString());
Log.debug(arg0.toString());
}
/**
* @see ymsg.network.event.SessionListener#friendAddedReceived(ymsg.network.event.SessionFriendEvent)
*/
public void friendAddedReceived(SessionFriendEvent arg0) {
logger.finest(arg0.toString());
Log.debug(arg0.toString());
}
/**
* @see ymsg.network.event.SessionListener#friendRemovedReceived(ymsg.network.event.SessionFriendEvent)
*/
public void friendRemovedReceived(SessionFriendEvent arg0) {
logger.finest(arg0.toString());
Log.debug(arg0.toString());
}
/**
* @see ymsg.network.event.SessionListener#chatLogonReceived(ymsg.network.event.SessionChatEvent)
*/
public void chatLogonReceived(SessionChatEvent arg0) {
logger.finest(arg0.toString());
Log.debug(arg0.toString());
}
/**
* @see ymsg.network.event.SessionListener#chatLogoffReceived(ymsg.network.event.SessionChatEvent)
*/
public void chatLogoffReceived(SessionChatEvent arg0) {
logger.finest(arg0.toString());
Log.debug(arg0.toString());
}
/**
* @see ymsg.network.event.SessionListener#chatMessageReceived(ymsg.network.event.SessionChatEvent)
*/
public void chatMessageReceived(SessionChatEvent arg0) {
logger.finest(arg0.toString());
Log.debug(arg0.toString());
}
/**
* @see ymsg.network.event.SessionListener#chatUserUpdateReceived(ymsg.network.event.SessionChatEvent)
*/
public void chatUserUpdateReceived(SessionChatEvent arg0) {
logger.finest(arg0.toString());
Log.debug(arg0.toString());
}
/**
* @see ymsg.network.event.SessionListener#chatConnectionClosed(ymsg.network.event.SessionEvent)
*/
public void chatConnectionClosed(SessionEvent arg0) {
logger.finest(arg0.toString());
Log.debug(arg0.toString());
}
}
......@@ -12,8 +12,9 @@ package org.jivesoftware.wildfire.gateway.protocols.yahoo;
import java.util.PropertyResourceBundle;
import java.util.ResourceBundle;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.jivesoftware.util.Log;
import org.jivesoftware.util.LocaleUtils;
import org.jivesoftware.wildfire.gateway.Gateway;
import org.jivesoftware.wildfire.gateway.roster.AbstractForeignContact;
......@@ -109,17 +110,13 @@ public class YahooForeignContact extends AbstractForeignContact {
status.updateValue(resource.getString("STATUS_TYPING"));
}
else {
logger.log(Level.WARNING, "yahooforeigncontact.unabletolocatestatus");
Log.warn(LocaleUtils.getLocalizedString("yahooforeigncontact.unabletolocatestatus", "gateway"));
status.updateValue("????");
}
return status;
}
/** The logger. */
final static private Logger logger = Logger.getLogger("yahooforeigncontact",
"gateway_i18n");
/** The resource. */
private static ResourceBundle resource = PropertyResourceBundle.getBundle("yahoostatus");
......
......@@ -10,8 +10,6 @@
package org.jivesoftware.wildfire.gateway.protocols.yahoo;
import java.util.logging.Logger;
import org.jivesoftware.wildfire.gateway.BaseGateway;
import org.jivesoftware.wildfire.gateway.GatewaySession;
import org.jivesoftware.wildfire.gateway.SubscriptionInfo;
......@@ -52,9 +50,6 @@ public class YahooGateway extends BaseGateway {
return "Yahoo! Gateway (ymsg9)";
}
/** The logger. @see java.util.logging.Logger */
static public final Logger logger = Logger.getLogger("YahooGateway");
/**
* @see org.jivesoftware.wildfire.gateway.Endpoint#sendPacket(Packet)
*/
......
......@@ -12,13 +12,12 @@ package org.jivesoftware.wildfire.gateway.protocols.yahoo;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.Vector;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.jivesoftware.wildfire.gateway.AbstractGatewaySession;
import org.jivesoftware.wildfire.gateway.Endpoint;
......@@ -31,6 +30,8 @@ import org.jivesoftware.wildfire.gateway.roster.ForeignContact;
import org.jivesoftware.wildfire.gateway.roster.NormalizedJID;
import org.jivesoftware.wildfire.gateway.roster.PersistenceManager;
import org.jivesoftware.wildfire.gateway.roster.UnknownForeignContactException;
import org.jivesoftware.util.Log;
import org.jivesoftware.util.LocaleUtils;
import org.xmpp.packet.JID;
import org.xmpp.packet.Message;
import org.xmpp.packet.Packet;
......@@ -50,9 +51,6 @@ import ymsg.network.YahooUser;
*/
public class YahooGatewaySession extends AbstractGatewaySession implements Endpoint {
/** The logger. */
private static Logger logger = Logger.getLogger("YahooGatewaySession", "gateway_i18n");
/**
* Yahoo Session
*/
......@@ -98,7 +96,7 @@ public class YahooGatewaySession extends AbstractGatewaySession implements Endpo
// Vector members = group.getMembers();
// for(Object member : members) {
// YahooUser user = (YahooUser)member;
// logger.info("Adding foreign contact: " + user.getId());
// Log.info("Adding foreign contact: " + user.getId());
// String foreignId = user.getId();
// NormalizedJID whois = NormalizedJID.wrap(gateway.whois(foreignId));
// AbstractForeignContact fc = PersistenceManager.Factory.get(gateway)
......@@ -106,15 +104,15 @@ public class YahooGatewaySession extends AbstractGatewaySession implements Endpo
// .getForeignContact(foreignId, gateway);
//
// if(fc == null || fc.status == null) {
// logger.warning("Unable to find Foreign Contact for: " + whois);
// Log.warn("Unable to find Foreign Contact for: " + whois);
// continue;
// }
// if(user == null) {
// logger.warning("Invalid Yahoo user");
// Log.warn("Invalid Yahoo user");
// continue;
// }
// if(fc.status.getValue() != null && !fc.status.getValue().equalsIgnoreCase(user.getCustomStatusMessage())) {
// logger.log(Level.FINE, "yahoogatewaysession.status", new Object[] {fc.status});
// Log.debug(LocaleUtils.getLocalizedString("yahoogatewaysession.status", "gateway", Arrays.asList(new Object[] {fc.status})));
// try {
// Presence p = new Presence();
// if(!fc.status.isSubscribed()) {
......@@ -152,7 +150,7 @@ public class YahooGatewaySession extends AbstractGatewaySession implements Endpo
* Password is stored in the JVM as a string in JVM
* util termination.
*/
logger.log(Level.INFO, "yahoogatewaysession.login", new Object[]{jid, getSubscriptionInfo().username});
Log.info(LocaleUtils.getLocalizedString("yahoogatewaysession.login", "gateway", Arrays.asList(new Object[]{jid, getSubscriptionInfo().username})));
getJabberEndpoint().getValve().open(); // allow any buffered messages to pass through
// updatePresence();
}
......@@ -161,7 +159,7 @@ public class YahooGatewaySession extends AbstractGatewaySession implements Endpo
if (loginFailedCount++ > 3) {
loginFailed = true;
}
logger.warning("Login failed for " + getSubscriptionInfo().username);
Log.warn("Login failed for " + getSubscriptionInfo().username);
}
catch (IOException ioe) {
ioe.printStackTrace();
......@@ -171,7 +169,7 @@ public class YahooGatewaySession extends AbstractGatewaySession implements Endpo
}.run(); // intentionally not forked.
}
else {
logger.warning(this.jid + " is already logged in");
Log.warn(this.jid + " is already logged in");
}
}
......@@ -188,7 +186,7 @@ public class YahooGatewaySession extends AbstractGatewaySession implements Endpo
* @throws Exception
*/
public synchronized void logout() throws Exception {
logger.info("[" + this.jid + "]" + getSubscriptionInfo().username + " logged out.");
Log.info("[" + this.jid + "]" + getSubscriptionInfo().username + " logged out.");
session.logout();
session.reset();
}
......@@ -287,14 +285,14 @@ public class YahooGatewaySession extends AbstractGatewaySession implements Endpo
* @param packet incoming packet from XMPP Server (typically from client)
*/
public void sendPacket(Packet packet) {
logger.log(Level.FINE, packet.toString());
Log.debug(packet.toString());
if (packet instanceof Message) {
Message m = (Message)packet;
try {
session.sendMessage(packet.getTo().getNode(), m.getBody());
}
catch (IOException ioe) {
logger.warning(ioe.getLocalizedMessage());
Log.warn(ioe.getLocalizedMessage());
}
}
}
......
......@@ -10,13 +10,15 @@
package org.jivesoftware.wildfire.gateway.protocols.yahoo;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.xmpp.component.ComponentException;
import org.xmpp.packet.Message;
import org.xmpp.packet.Presence;
import java.util.Arrays;
import org.jivesoftware.util.Log;
import org.jivesoftware.util.LocaleUtils;
import ymsg.network.event.SessionChatEvent;
import ymsg.network.event.SessionEvent;
import ymsg.network.event.SessionFriendEvent;
......@@ -35,9 +37,6 @@ public class YahooSessionListener extends NoopSessionListener {
*/
private YahooGatewaySession gatewaySession;
/** The logger. */
private static final Logger logger = Logger.getLogger("YahooSessionListener");
/**
* Creates a YahooSessionListener that will translate events from the Yahoo!
* connection into XMPP formated packets.
......@@ -62,7 +61,7 @@ public class YahooSessionListener extends NoopSessionListener {
gatewaySession.getJabberEndpoint().sendPacket(message);
}
catch (Exception e) {
logger.severe("Unable to send message: " + e.getLocalizedMessage());
Log.error("Unable to send message: " + e.getLocalizedMessage());
}
}
......@@ -71,7 +70,7 @@ public class YahooSessionListener extends NoopSessionListener {
*/
@Override
public void messageReceived(SessionEvent sessionEvent) {
logger.finest(sessionEvent.toString());
Log.debug(sessionEvent.toString());
try {
Message message = new Message();
......@@ -80,10 +79,10 @@ public class YahooSessionListener extends NoopSessionListener {
message.setType(Message.Type.chat);
message.setFrom(this.gatewaySession.getGateway().whois(sessionEvent.getFrom()));
gatewaySession.getJabberEndpoint().sendPacket(message);
logger.fine(message.getElement().asXML());
Log.debug(message.getElement().asXML());
}
catch (Exception e) {
logger.severe("unable to send message: "+ e.getLocalizedMessage());
Log.error("unable to send message: "+ e.getLocalizedMessage());
}
}
......@@ -96,7 +95,7 @@ public class YahooSessionListener extends NoopSessionListener {
updateStatus(event);
}
catch (Exception e) {
logger.log(Level.SEVERE, "yahoosessionlistener.friendupdateerror", e.getLocalizedMessage());
Log.debug(LocaleUtils.getLocalizedString("yahoosessionlistener.friendupdateerror", "gateway", Arrays.asList(e.getLocalizedMessage())));
}
}
......@@ -119,7 +118,7 @@ public class YahooSessionListener extends NoopSessionListener {
*/
@Override
public void chatMessageReceived(SessionChatEvent sessionEvent) {
logger.finer(sessionEvent.toString());
Log.debug(sessionEvent.toString());
try {
Message message = new Message();
message.setTo(gatewaySession.getSessionJID());
......@@ -128,7 +127,7 @@ public class YahooSessionListener extends NoopSessionListener {
gatewaySession.getJabberEndpoint().sendPacket(message);
}
catch (Exception e) {
logger.severe("unable to send message: "+ e.getLocalizedMessage());
Log.error("unable to send message: "+ e.getLocalizedMessage());
}
}
......
......@@ -10,6 +10,8 @@
package org.jivesoftware.wildfire.gateway.roster;
import java.io.Serializable;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
......@@ -23,7 +25,9 @@ import org.xmpp.packet.JID;
*
* @author Noah Campbell
*/
public class ContactManager {
public class ContactManager implements Serializable {
private static final long serialVersionUID = 1L;
/**
* Construct a new <code>ContactManager</code>
......
......@@ -10,6 +10,8 @@
package org.jivesoftware.wildfire.gateway.roster;
import java.io.Serializable;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
......@@ -21,7 +23,9 @@ import org.xmpp.packet.JID;
* @author Noah Campbell
*
*/
public final class NormalizedJID {
public final class NormalizedJID implements Serializable {
private static final long serialVersionUID = 1L;
/**
* The JID.
......
......@@ -10,6 +10,7 @@
package org.jivesoftware.wildfire.gateway.roster;
import java.io.Serializable;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
......@@ -20,8 +21,6 @@ import java.util.Map;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.prefs.Preferences;
import javax.crypto.Cipher;
......@@ -33,7 +32,8 @@ import javax.crypto.spec.SecretKeySpec;
import org.jivesoftware.wildfire.gateway.Gateway;
import org.jivesoftware.wildfire.gateway.util.BackgroundThreadFactory;
import org.jivesoftware.wildfire.gateway.util.GatewayLevel;
import org.jivesoftware.util.Log;
import org.jivesoftware.util.LocaleUtils;
import org.xmpp.packet.JID;
/**
......@@ -45,7 +45,9 @@ import org.xmpp.packet.JID;
* @author Noah Campbell
*
*/
public class PersistenceManager {
public class PersistenceManager implements Serializable {
private static final long serialVersionUID = 1L;
/**
* The contactManager.
......@@ -130,7 +132,7 @@ public class PersistenceManager {
registrar.remove(jid);
}
catch (Exception e) {
logger.severe("Unable to remove " + bareJID + ": " + e.getLocalizedMessage());
Log.error("Unable to remove " + bareJID + ": " + e.getLocalizedMessage());
}
}
......@@ -149,7 +151,7 @@ public class PersistenceManager {
byte[] rawKey = Preferences.systemNodeForPackage(this.getClass()).getByteArray(".key", null);
if (rawKey == null) {
logger.log(GatewayLevel.SECURITY, "persistencemanager.nokey");
Log.error(LocaleUtils.getLocalizedString("persistencemanager.nokey", "gateway"));
return;
}
......@@ -168,7 +170,7 @@ public class PersistenceManager {
if (db.exists()) {
db.delete();
}
logger.log(Level.WARNING, "persistencemanager.loadrosterfailed",e);
Log.warn(LocaleUtils.getLocalizedString("persistencemanager.loadrosterfailed", "gateway"), e);
}
finally {
this.contactManager = (contactManager != null) ? contactManager : new ContactManager();
......@@ -184,13 +186,6 @@ public class PersistenceManager {
*/
private final ScheduledExecutorService timer = Executors.newScheduledThreadPool(1, new BackgroundThreadFactory());
/**
* The logger.
*
* @see PersistenceManager
*/
private static final Logger logger = Logger.getLogger("PersistenceManager", "gateway_i18n");
/**
* Responsible for flushing the in-memory database.
*/
......@@ -200,7 +195,7 @@ public class PersistenceManager {
store();
}
catch (Exception e) {
logger.log(Level.WARNING, "persistencemanager.unabletoflush", e);
Log.warn(LocaleUtils.getLocalizedString("persistencemanager.unabletoflush", "gateway"), e);
e.printStackTrace();
}
}
......@@ -216,7 +211,7 @@ public class PersistenceManager {
byte[] rawKey = prefs.getByteArray(".key", null);
if (rawKey == null) {
logger.log(GatewayLevel.SECURITY, "persistencemanager.gennewkey");
Log.error(LocaleUtils.getLocalizedString("persistencemanager.gennewkey", "gateway"));
KeyGenerator kg = KeyGenerator.getInstance("AES");
SecretKey key = kg.generateKey();
rawKey = key.getEncoded();
......@@ -255,7 +250,7 @@ public class PersistenceManager {
protected void finalize() throws Throwable {
super.finalize();
this.timer.shutdownNow();
logger.log(Level.FINER, "persistencemanager.registrarFinalize");
Log.debug(LocaleUtils.getLocalizedString("persistencemanager.registrarFinalize", "gateway"));
}
}
......@@ -10,16 +10,17 @@
package org.jivesoftware.wildfire.gateway.roster;
import java.io.Serializable;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Logger;
import org.jivesoftware.wildfire.gateway.Gateway;
import org.jivesoftware.wildfire.gateway.GatewaySession;
import org.jivesoftware.wildfire.gateway.SubscriptionInfo;
import org.jivesoftware.util.Log;
import org.xmpp.packet.JID;
/**
......@@ -29,7 +30,9 @@ import org.xmpp.packet.JID;
*
* @author Noah Campbell
*/
public class Registrar {
public class Registrar implements Serializable {
private static final long serialVersionUID = 1L;
/**
* Construct a new <code>Registrar</code>.
......@@ -93,7 +96,7 @@ public class Registrar {
GatewaySession session = this.gateway.getSessionFactory().newInstance(info);
session.login();
logger.info("Creating session for: " + jid);
Log.info("Creating session for: " + jid);
sessions.put(jid, session);
}
return sessions.get(jid);
......@@ -120,13 +123,6 @@ public class Registrar {
*/
private transient Gateway gateway;
/**
* The logger.
*
* @see Registrar
*/
private static final Logger logger = Logger.getLogger("Registrar");
/**
* Removes the NormalizedJID from the registrar.
* @param jid
......
......@@ -10,6 +10,7 @@
package org.jivesoftware.wildfire.gateway.roster;
import java.io.Serializable;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
......@@ -27,7 +28,9 @@ import org.jivesoftware.wildfire.gateway.Gateway;
* @see org.xmpp.packet.JID
* @deprecated
*/
public class Roster {
public class Roster implements Serializable {
private static final long serialVersionUID = 1L;
/**
* The foreignContacts.
......
......@@ -10,12 +10,16 @@
package org.jivesoftware.wildfire.gateway.roster;
import java.io.Serializable;
/**
* Status object.
*
* @author Noah Campbell
*/
public final class Status {
private static final long serialVersionUID = 1L;
/** The subscribed. */
private boolean subscribed = false;
......
/**
* $Revision$
* $Date$
*
* Copyright (C) 2006 Jive Software. All rights reserved.
*
* This software is published under the terms of the GNU Public License (GPL),
* a copy of which is included in this distribution.
*/
package org.jivesoftware.wildfire.gateway.util;
import java.util.logging.Level;
/**
* Custom log levels.
*
* @author Noah Campbell
* @see java.util.logging.Level
*/
public class GatewayLevel extends Level {
/** SECURITY log level. */
public static final Level SECURITY = new GatewayLevel("SECURITY", 501);
/**
* Construct a new <code>GatewayLevel</code>.
*
* @param name
* @param value
*/
protected GatewayLevel(String name, int value) {
super(name, value, "gateway_i18n");
}
}
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