Commit 990969a8 authored by Matt Tucker's avatar Matt Tucker Committed by matt

More refactoring work. Deleted database schemas not under active development...

More refactoring work. Deleted database schemas not under active development -- will add back when development is further along.

git-svn-id: http://svn.igniterealtime.org/svn/repos/wildfire/trunk@4416 b35dd754-fafc-0310-a699-88a17e54d16e
parent 249d74f7
CREATE TABLE gatewayRegistration (
gwID VARCHAR(50) NOT NULL,
username VARCHAR(64) NOT NULL,
legacyAcct VARCHAR(255) NOT NULL,
legacyPwd VARCHAR(255) NOT NULL,
CONSTRAINT gatewayRegistration_pk PRIMARY KEY (gwID, username)
);
INSERT INTO jiveVersion (name, version) VALUES ('gateway', 0);
CREATE TABLE gatewayRegistration (
gwID VARCHAR(50) NOT NULL,
username VARCHAR(64) NOT NULL,
legacyAcct VARCHAR(255) NOT NULL,
legacyPwd VARCHAR(255) NOT NULL,
CONSTRAINT gatewayRegistration_pk PRIMARY KEY (gwID, username)
regisrationID BIGINT NOT NULL,
jid VARCHAR(1024) NOT NULL,
gatewayType VARCHAR(15) NOT NULL,
username VARCHAR(255) NOT NULL,
password VARCHAR(255),
registrationDate BIGINT NOT NULL,
lastLogin BIGINT,
CONSTRAINT gatewayReg_pk PRIMARY KEY (registrationID);
);
CREATE INDEX gatewayReg_jid_idx ON gatewayRegistration (jid);
CREATE INDEX gatewayReg_type_idx ON gatewayRegistration (gatewayType);
INSERT INTO jiveVersion (name, version) VALUES ('gateway', 0);
CREATE TABLE gatewayRegistration (
gwID VARCHAR(50) NOT NULL,
username VARCHAR(64) NOT NULL,
legacyAcct VARCHAR(255) NOT NULL,
legacyPwd VARCHAR(255) NOT NULL,
primary key (gwID, username)
regisrationID BIGINT NOT NULL,
jid TEXT NOT NULL,
gatewayType VARCHAR(15) NOT NULL,
username VARCHAR(255) NOT NULL,
password VARCHAR(255),
registrationDate BIGINT NOT NULL,
lastLogin BIGINT,
PRIMARY KEY (registrationID),
INDEX gatewayReg_jid_idx(jid),
INDEX gatewayReg_type_idx(gatewayType)
);
INSERT INTO jiveVersion (name, version) VALUES ('gateway', 0);
INSERT INTO jiveVersion (name, version) VALUES ('gateway', 0);
\ No newline at end of file
CREATE TABLE gatewayRegistration (
gwID VARCHAR2(50) NOT NULL,
username VARCHAR2(64) NOT NULL,
legacyAcct VARCHAR2(255) NOT NULL,
legacyPwd VARCHAR2(255) NOT NULL,
CONSTRAINT gatewayRegistration_pk PRIMARY KEY (gwID, username)
);
INSERT INTO jiveVersion (name, version) VALUES ('gateway', 0);
CREATE TABLE gatewayRegistration (
gwID VARCHAR(50) NOT NULL,
username VARCHAR(64) NOT NULL,
legacyAcct VARCHAR(255) NOT NULL,
legacyPwd VARCHAR(255) NOT NULL,
CONSTRAINT gatewayRegistration_pk PRIMARY KEY (gwID, username)
);
INSERT INTO jiveVersion (name, version) VALUES ('gateway', 0);
CREATE TABLE gatewayRegistration (
gwID NVARCHAR(50) NOT NULL,
username NVARCHAR(64) NOT NULL,
legacyAcct NVARCHAR(255) NOT NULL,
legacyPwd NVARCHAR(255) NOT NULL,
CONSTRAINT gatewayRegistration_pk PRIMARY KEY (gwID, username)
);
INSERT INTO jiveVersion (name, version) VALUES ('gateway', 0);
CREATE TABLE gatewayRegistration (
gwID NVARCHAR(50) NOT NULL,
username NVARCHAR(64) NOT NULL,
legacyAcct NVARCHAR(255) NOT NULL,
legacyPwd NVARCHAR(255) NOT NULL,
CONSTRAINT gatewayRegistration_pk PRIMARY KEY (gwID, username)
);
INSERT INTO jiveVersion (name, version) VALUES ('gateway', 0);
......@@ -13,7 +13,10 @@ package org.jivesoftware.wildfire.gateway;
import org.xmpp.packet.JID;
/**
* A gateway to an external or legacy messaging system.
* A gateway to an external or legacy messaging system. Users of the XMPP server register
* with the gateway by providing their login credentials with the external system. The
* gateway then logs into the external system on the user's behalf and translates IM
* data between the user's XMPP account and the external system.
*
* @author ncampbell
*/
......
......@@ -22,7 +22,8 @@ import java.io.File;
import java.util.Hashtable;
/**
* IM Gateway plugin.
* IM Gateway plugin, which provides connectivity to IM networks that don't support
* the XMPP protocol.
*
* @author Daniel Henninger
*/
......@@ -47,15 +48,18 @@ public class GatewayPlugin implements Plugin {
componentManager = ComponentManagerFactory.getComponentManager();
/* Set up AIM gateway. */
gateways.put("aim", new GatewayInstance("aim", "org.jivesoftware.wildfire.gateway.protocols.oscar.OSCARGateway", componentManager));
gateways.put("aim", new GatewayInstance("aim",
"org.jivesoftware.wildfire.gateway.protocols.oscar.OSCARGateway", componentManager));
maybeStartService("aim");
/* Set up ICQ gateway. */
gateways.put("icq", new GatewayInstance("icq", "org.jivesoftware.wildfire.gateway.protocols.oscar.OSCARGateway", componentManager));
gateways.put("icq", new GatewayInstance("icq",
"org.jivesoftware.wildfire.gateway.protocols.oscar.OSCARGateway", componentManager));
maybeStartService("icq");
/* Set up Yahoo gateway. */
gateways.put("yahoo", new GatewayInstance("yahoo", "org.jivesoftware.wildfire.gateway.protocols.yahoo.YahooGateway", componentManager));
gateways.put("yahoo", new GatewayInstance("yahoo",
"org.jivesoftware.wildfire.gateway.protocols.yahoo.YahooGateway", componentManager));
maybeStartService("yahoo");
}
......
......@@ -13,8 +13,16 @@ package org.jivesoftware.wildfire.gateway;
import org.xmpp.packet.JID;
import org.jivesoftware.wildfire.auth.AuthFactory;
import org.jivesoftware.util.NotFoundException;
import org.jivesoftware.util.Log;
import org.jivesoftware.database.DbConnectionManager;
import org.jivesoftware.database.JiveID;
import org.jivesoftware.database.SequenceManager;
import java.util.Date;
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
/**
* Contains information about the registration a user has made with an external gateway.
......@@ -26,8 +34,17 @@ import java.util.Date;
*
* @author Matt Tucker
*/
@JiveID(125)
public class Registration {
private static final String INSERT_REGISTRATION =
"INSERT INTO entConversation(registrationID, jid, gatewayType, " +
"username, password, registrationDate) VALUES (?,?,?,?,?,?)";
private static final String LOAD_REGISTRATION =
"SELECT jid, gatewayType, username, password, registrationDate, lastLogin " +
"FROM gatewayRegistration WHERE registrationID=?";
private long registrationID;
private JID jid;
private GatewayType gatewayType;
private String username;
......@@ -47,32 +64,31 @@ public class Registration {
if (jid == null || gatewayType == null || username == null) {
throw new NullPointerException("Arguments cannot be null.");
}
this.jid = jid;
// Ensure that we store the bare JID.
this.jid = new JID(jid.toBareJID());
this.gatewayType = gatewayType;
this.username = username;
this.password = password;
this.registrationDate = new Date();
// todo: insert into db
try {
insertIntoDb();
}
catch (Exception e) {
Log.error(e);
}
}
/**
* Loads an existing registration.
*
* @param jid the JID of the user making the registration.
* @param gatewayType the type of the gateway.
* @param username the username on the gateway.
* @param registrationID the ID of the registration.
* @throws NotFoundException if the registration could not be loaded.
*/
public Registration(JID jid, GatewayType gatewayType, String username)
public Registration(long registrationID)
throws NotFoundException
{
if (jid == null || gatewayType == null || username == null) {
throw new NullPointerException("Arguments cannot be null.");
}
this.jid = jid;
this.gatewayType = gatewayType;
this.username = username;
// todo: load from db
this.registrationID = registrationID;
loadFromDb();
}
/**
......@@ -153,4 +169,64 @@ public class Registration {
return jid + ", " + gatewayType + ", " + username;
}
/**
* Inserts a new registration into the database.
*/
private void insertIntoDb() throws SQLException {
this.registrationID = SequenceManager.nextID(this);
Connection con = null;
PreparedStatement pstmt = null;
boolean abortTransaction = false;
try {
con = DbConnectionManager.getTransactionConnection();
pstmt = con.prepareStatement(INSERT_REGISTRATION);
pstmt.setLong(1, registrationID);
pstmt.setString(2, jid.toString());
pstmt.setString(3, gatewayType.name());
pstmt.setString(4, username);
pstmt.setString(5, password);
pstmt.setLong(6, registrationDate.getTime());
pstmt.executeUpdate();
}
catch (SQLException sqle) {
abortTransaction = true;
throw sqle;
}
finally {
DbConnectionManager.closeTransactionConnection(pstmt, con, abortTransaction);
}
}
private void loadFromDb() throws NotFoundException {
Connection con = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
try {
con = DbConnectionManager.getConnection();
pstmt = con.prepareStatement(LOAD_REGISTRATION);
pstmt.setLong(1, registrationID);
rs = pstmt.executeQuery();
if (!rs.next()) {
throw new NotFoundException("Registration not found: " + registrationID);
}
this.jid = new JID(rs.getString(1));
this.gatewayType = GatewayType.valueOf(rs.getString(2));
this.username = rs.getString(3);
this.password = rs.getString(4);
this.registrationDate = new Date(rs.getLong(5));
long loginDate = rs.getLong(6);
if (rs.wasNull()) {
this.lastLogin = null;
}
else {
this.lastLogin = new Date(loginDate);
}
}
catch (SQLException sqle) {
Log.error(sqle);
}
finally {
DbConnectionManager.closeConnection(rs, pstmt, con);
}
}
}
\ No newline at end of file
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