Commit bad5859d authored by guus's avatar guus

* Updating 'clientControl' plugin to make use of SLF4J instead of custom logging (OF-53).

* Applied java generics.

git-svn-id: http://svn.igniterealtime.org/svn/repos/openfire/trunk@11440 b35dd754-fafc-0310-a699-88a17e54d16e
parent bfdfcae7
......@@ -44,6 +44,13 @@
Client Control Plugin Changelog
</h1>
<p><b>1.1.0</b> -- December 1, 2009</p>
<ul>
<li>Now requires Openfire 3.6.5.</li>
<li>Applied Java generics.</li>
<li>[<a href='http://www.igniterealtime.org/issues/browse/OF-53'>OF-53</a>] - Replace custom logging implementation with a third party library.</li>
</ul>
<p><b>1.0.3</b> -- August 27, 2008</p>
<ul>
<li>Upgraded for Openfire 3.6.0 API.</li>
......
......@@ -8,9 +8,9 @@
<name>Client Control</name>
<description>Controls clients allowed to connect and available features</description>
<author>Jive Software</author>
<version>1.0.3</version>
<date>8/27/2008</date>
<minServerVersion>3.6.0</minServerVersion>
<version>1.1.0</version>
<date>12/1/2009</date>
<minServerVersion>3.6.5</minServerVersion>
<databaseKey>clientcontrol</databaseKey>
<databaseVersion>0</databaseVersion>
......
......@@ -19,12 +19,6 @@
package org.jivesoftware.openfire.plugin.spark;
import org.jivesoftware.database.DbConnectionManager;
import org.jivesoftware.database.JiveID;
import org.jivesoftware.database.SequenceManager;
import org.jivesoftware.util.Log;
import org.jivesoftware.util.NotFoundException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
......@@ -38,6 +32,13 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.jivesoftware.database.DbConnectionManager;
import org.jivesoftware.database.JiveID;
import org.jivesoftware.database.SequenceManager;
import org.jivesoftware.util.NotFoundException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Represents a Bookmark. Each bookmark can apply to a set of users and groups, or to
* everyone in the system. There are two types of bookmarks:<ul>
......@@ -63,6 +64,8 @@ import java.util.Map;
@JiveID(55)
public class Bookmark {
private static final Logger Log = LoggerFactory.getLogger(Bookmark.class);
private static final String INSERT_BOOKMARK =
"INSERT INTO ofBookmark(bookmarkID, bookmarkType, bookmarkName, bookmarkValue, " +
"isGlobal) VALUES (?,?,?,?,?)";
......@@ -70,8 +73,8 @@ public class Bookmark {
"INSERT INTO ofBookmarkPerm(bookmarkID, bookmarkType, name) VALUES(?,?,?)";
private static final String LOAD_BOOKMARK_PERMISSIONS =
"SELECT bookmarkType, name FROM ofBookmarkPerm WHERE bookmarkID=?";
private static final String SAVE_BOOKMARK_PERMISSIONS =
"UPDATE ofBookmarkPerm SET bookmarkType=?, name=? WHERE bookmarkID=?";
// private static final String SAVE_BOOKMARK_PERMISSIONS =
// "UPDATE ofBookmarkPerm SET bookmarkType=?, name=? WHERE bookmarkID=?";
private static final String DELETE_BOOKMARK_PERMISSIONS =
"DELETE from ofBookmarkPerm WHERE bookmarkID=?";
private static final String SAVE_BOOKMARK =
......@@ -120,7 +123,7 @@ public class Bookmark {
insertBookmarkPermissions();
}
catch (Exception e) {
Log.error(e);
Log.error(e.getMessage(), e);
}
}
......@@ -360,7 +363,7 @@ public class Bookmark {
*
* @return an Iterator for the names of the extended properties.
*/
public Iterator getPropertyNames() {
public Iterator<String> getPropertyNames() {
if (properties == null) {
loadPropertiesFromDb();
}
......@@ -418,7 +421,7 @@ public class Bookmark {
deleteBookmarkPermissions();
}
catch (SQLException e) {
Log.error(e);
Log.error(e.getMessage(), e);
}
// Persist users
......@@ -428,7 +431,7 @@ public class Bookmark {
insertBookmarkPermission(USERS, user);
}
catch (SQLException e) {
Log.error(e);
Log.error(e.getMessage(), e);
}
}
}
......@@ -439,7 +442,7 @@ public class Bookmark {
insertBookmarkPermission(GROUPS, group);
}
catch (SQLException e) {
Log.error(e);
Log.error(e.getMessage(), e);
}
}
}
......@@ -514,7 +517,7 @@ public class Bookmark {
groups = groupList;
}
catch (SQLException sqle) {
Log.error(sqle);
Log.error(sqle.getMessage(), sqle);
}
finally {
DbConnectionManager.closeConnection(rs, pstmt, con);
......@@ -547,7 +550,7 @@ public class Bookmark {
pstmt.close();
}
catch (SQLException sqle) {
Log.error(sqle);
Log.error(sqle.getMessage(), sqle);
}
finally {
DbConnectionManager.closeConnection(rs, pstmt, con);
......@@ -573,7 +576,7 @@ public class Bookmark {
}
catch (SQLException sqle) {
abortTransaction = true;
Log.error(sqle);
Log.error(sqle.getMessage(), sqle);
}
finally {
DbConnectionManager.closeTransactionConnection(con, abortTransaction);
......@@ -600,7 +603,7 @@ public class Bookmark {
rs.close();
}
catch (SQLException sqle) {
Log.error(sqle);
Log.error(sqle.getMessage(), sqle);
}
finally {
DbConnectionManager.closeConnection(pstmt, con);
......@@ -623,7 +626,7 @@ public class Bookmark {
pstmt.executeUpdate();
}
catch (SQLException sqle) {
Log.error(sqle);
Log.error(sqle.getMessage(), sqle);
abortTransaction = true;
}
finally {
......@@ -647,7 +650,7 @@ public class Bookmark {
pstmt.executeUpdate();
}
catch (SQLException sqle) {
Log.error(sqle);
Log.error(sqle.getMessage(), sqle);
abortTransaction = true;
}
finally {
......@@ -670,7 +673,7 @@ public class Bookmark {
pstmt.execute();
}
catch (SQLException sqle) {
Log.error(sqle);
Log.error(sqle.getMessage(), sqle);
abortTransaction = true;
}
finally {
......
......@@ -16,8 +16,10 @@
package org.jivesoftware.openfire.plugin.spark;
import java.util.Collection;
import java.util.Iterator;
import org.dom4j.Element;
import org.jivesoftware.util.Log;
import org.jivesoftware.openfire.group.Group;
import org.jivesoftware.openfire.group.GroupManager;
import org.jivesoftware.openfire.group.GroupNotFoundException;
......@@ -27,13 +29,12 @@ import org.jivesoftware.openfire.interceptor.PacketRejectedException;
import org.jivesoftware.openfire.session.Session;
import org.jivesoftware.openfire.user.UserManager;
import org.jivesoftware.openfire.user.UserNotFoundException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.xmpp.packet.IQ;
import org.xmpp.packet.JID;
import org.xmpp.packet.Packet;
import java.util.Collection;
import java.util.Iterator;
/**
* Intercepts Bookmark Storage requests and appends all server based Bookmarks to
* the result.
......@@ -42,6 +43,8 @@ import java.util.Iterator;
*/
public class BookmarkInterceptor implements PacketInterceptor {
private static final Logger Log = LoggerFactory.getLogger(BookmarkInterceptor.class);
/**
* Initializes the BookmarkInterceptor and needed Server instances.
*/
......@@ -138,7 +141,7 @@ public class BookmarkInterceptor implements PacketInterceptor {
}
}
catch (GroupNotFoundException e) {
Log.debug(e);
Log.debug(e.getMessage(), e);
}
}
}
......@@ -200,7 +203,7 @@ public class BookmarkInterceptor implements PacketInterceptor {
}
catch (Exception e) {
Log.error(e);
Log.error(e.getMessage(), e);
}
}
}
......@@ -224,9 +227,9 @@ public class BookmarkInterceptor implements PacketInterceptor {
private static Element urlExists(Element element, String url) {
// Iterate through current elements to see if this url already exists.
// If one does not exist, then add the bookmark.
final Iterator urlBookmarks = element.elementIterator("url");
final Iterator<Element> urlBookmarks = element.elementIterator("url");
while (urlBookmarks.hasNext()) {
Element urlElement = (Element)urlBookmarks.next();
Element urlElement = urlBookmarks.next();
String urlValue = urlElement.attributeValue("url");
if (urlValue.equalsIgnoreCase(url)) {
return urlElement;
......@@ -246,9 +249,9 @@ public class BookmarkInterceptor implements PacketInterceptor {
private Element conferenceExists(Element element, String roomJID) {
// Iterate through current elements to see if the conference bookmark
// already exists.
final Iterator conferences = element.elementIterator("conference");
final Iterator<Element> conferences = element.elementIterator("conference");
while (conferences.hasNext()) {
final Element conferenceElement = (Element)conferences.next();
final Element conferenceElement = conferences.next();
String jidValue = conferenceElement.attributeValue("jid");
if (jidValue != null && roomJID != null && jidValue.equalsIgnoreCase(roomJID)) {
......
......@@ -16,10 +16,6 @@
package org.jivesoftware.openfire.plugin.spark;
import org.jivesoftware.database.DbConnectionManager;
import org.jivesoftware.util.Log;
import org.jivesoftware.util.NotFoundException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
......@@ -28,6 +24,11 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import org.jivesoftware.database.DbConnectionManager;
import org.jivesoftware.util.NotFoundException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Manages global bookmarks. Bookmarks are defined by
* <a href="http://www.jabber.org/jeps/jep-0048.html">JEP-0048</a>. Users can define and
......@@ -39,6 +40,8 @@ import java.util.List;
*/
public class BookmarkManager {
private static final Logger Log = LoggerFactory.getLogger(BookmarkManager.class);
private static final String DELETE_BOOKMARK = "DELETE FROM ofBookmark where bookmarkID=?";
private static final String SELECT_BOOKMARKS = "SELECT bookmarkID from ofBookmark";
......@@ -77,12 +80,12 @@ public class BookmarkManager {
bookmarks.add(bookmark);
}
catch (NotFoundException nfe) {
Log.error(nfe);
Log.error(nfe.getMessage(), nfe);
}
}
}
catch (SQLException e) {
Log.error(e);
Log.error(e.getMessage(), e);
}
finally {
DbConnectionManager.closeConnection(rs, pstmt, con);
......@@ -107,7 +110,7 @@ public class BookmarkManager {
pstmt.execute();
}
catch (SQLException e) {
Log.error(e);
Log.error(e.getMessage(), e);
}
finally {
DbConnectionManager.closeConnection(pstmt, con);
......
......@@ -16,27 +16,33 @@
package org.jivesoftware.openfire.plugin.spark;
import org.jivesoftware.openfire.plugin.spark.manager.SparkVersionManager;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;
import java.util.TimerTask;
import java.util.concurrent.atomic.AtomicInteger;
import org.dom4j.Element;
import org.jivesoftware.openfire.SessionManager;
import org.jivesoftware.openfire.event.SessionEventDispatcher;
import org.jivesoftware.openfire.event.SessionEventListener;
import org.jivesoftware.openfire.plugin.spark.manager.SparkVersionManager;
import org.jivesoftware.openfire.session.ClientSession;
import org.jivesoftware.openfire.session.Session;
import org.jivesoftware.openfire.stats.StatisticsManager;
import org.jivesoftware.util.JiveGlobals;
import org.jivesoftware.util.Log;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.xmpp.component.Component;
import org.xmpp.component.ComponentException;
import org.xmpp.component.ComponentManager;
import org.xmpp.component.ComponentManagerFactory;
import org.xmpp.packet.*;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;
import java.util.TimerTask;
import java.util.concurrent.atomic.AtomicInteger;
import org.xmpp.packet.IQ;
import org.xmpp.packet.JID;
import org.xmpp.packet.Message;
import org.xmpp.packet.Packet;
import org.xmpp.packet.PacketError;
import org.xmpp.packet.StreamError;
/**
* Handles querying and notifications of enabled client features within the server, as well
......@@ -46,6 +52,8 @@ import java.util.concurrent.atomic.AtomicInteger;
*/
public class SparkManager implements Component {
private static final Logger Log = LoggerFactory.getLogger(SparkManager.class);
private static final String INVALID_DISCONNECTS_KEY = "disconnects";
private static final String SPARK_CLIENTS_KEY = "spark";
......@@ -89,7 +97,7 @@ public class SparkManager implements Component {
componentManager.addComponent(serviceName, this);
}
catch (Exception e) {
Log.error(e);
Log.error(e.getMessage(), e);
}
// Add VersionManager. This component is cluster-safe.
......@@ -97,7 +105,7 @@ public class SparkManager implements Component {
componentManager.addComponent(SparkVersionManager.SERVICE_NAME, new SparkVersionManager());
}
catch (Exception e) {
Log.error(e);
Log.error(e.getMessage(), e);
}
// Add SessionListener
......@@ -253,7 +261,7 @@ public class SparkManager implements Component {
componentManager.removeComponent(serviceName);
}
catch (ComponentException e) {
Log.error(e);
Log.error(e.getMessage(), e);
}
taskEngine = null;
......@@ -315,7 +323,7 @@ public class SparkManager implements Component {
componentManager.sendPacket(this, packet);
}
catch (ComponentException e) {
Log.error(e);
Log.error(e.getMessage(), e);
}
}
......
......@@ -17,7 +17,6 @@
package org.jivesoftware.openfire.plugin.spark;
import java.util.ArrayList;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
......@@ -247,22 +246,22 @@ public final class SparkUtil {
public static String getTimeFromLong(long diff) {
final String HOURS = "h";
final String MINUTES = "min";
final String SECONDS = "sec";
//final String SECONDS = "sec";
final long MS_IN_A_DAY = 1000 * 60 * 60 * 24;
final long MS_IN_AN_HOUR = 1000 * 60 * 60;
final long MS_IN_A_MINUTE = 1000 * 60;
final long MS_IN_A_SECOND = 1000;
Date currentTime = new Date();
long numDays = diff / MS_IN_A_DAY;
//Date currentTime = new Date();
//long numDays = diff / MS_IN_A_DAY;
diff = diff % MS_IN_A_DAY;
long numHours = diff / MS_IN_AN_HOUR;
diff = diff % MS_IN_AN_HOUR;
long numMinutes = diff / MS_IN_A_MINUTE;
diff = diff % MS_IN_A_MINUTE;
long numSeconds = diff / MS_IN_A_SECOND;
//long numSeconds = diff / MS_IN_A_SECOND;
diff = diff % MS_IN_A_SECOND;
long numMilliseconds = diff;
//long numMilliseconds = diff;
StringBuffer buf = new StringBuffer();
if (numHours > 0) {
......@@ -288,8 +287,8 @@ public final class SparkUtil {
/**
* Build a List of all elements in an Iterator.
*/
public static List iteratorAsList(Iterator i) {
ArrayList list = new ArrayList(10);
public static <E> List<E> iteratorAsList(Iterator<E> i) {
ArrayList<E> list = new ArrayList<E>(10);
while (i.hasNext()) {
list.add(i.next());
}
......@@ -299,18 +298,18 @@ public final class SparkUtil {
/**
* Creates an Iterator that is the reverse of a ListIterator.
*/
public static Iterator reverseListIterator(ListIterator i) {
return new ReverseListIterator(i);
public static <E> Iterator<E> reverseListIterator(ListIterator<E> i) {
return new ReverseListIterator<E>(i);
}
}
/**
* An Iterator that is the reverse of a ListIterator.
*/
class ReverseListIterator implements Iterator {
private ListIterator listIterator;
class ReverseListIterator<E> implements Iterator<E> {
private ListIterator<E> listIterator;
ReverseListIterator(ListIterator i) {
ReverseListIterator(ListIterator<E> i) {
listIterator = i;
while (listIterator.hasNext()) listIterator.next();
}
......@@ -319,7 +318,7 @@ class ReverseListIterator implements Iterator {
return listIterator.hasPrevious();
}
public Object next() {
public E next() {
return listIterator.previous();
}
......
......@@ -20,10 +20,13 @@
package org.jivesoftware.openfire.plugin.spark.manager;
import java.io.File;
import org.dom4j.Element;
import org.jivesoftware.util.JiveGlobals;
import org.jivesoftware.util.Log;
import org.jivesoftware.openfire.XMPPServer;
import org.jivesoftware.util.JiveGlobals;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.xmpp.component.Component;
import org.xmpp.component.ComponentException;
import org.xmpp.component.ComponentManager;
......@@ -33,8 +36,6 @@ import org.xmpp.packet.JID;
import org.xmpp.packet.Packet;
import org.xmpp.packet.PacketError;
import java.io.File;
/**
* Provides support for server administrators to control the global updating of the Jive Spark IM client.
* (<a href="http://www.igniterealtime.org/projects/spark/index.jsp">Spark</a>).<p>
......@@ -48,6 +49,8 @@ import java.io.File;
*/
public class SparkVersionManager implements Component {
private static final Logger Log = LoggerFactory.getLogger(SparkVersionManager.class);
private ComponentManager componentManager;
public static String SERVICE_NAME = "updater";
......@@ -231,7 +234,7 @@ public class SparkVersionManager implements Component {
componentManager.sendPacket(this, packet);
}
catch (ComponentException e) {
Log.error(e);
Log.error(e.getMessage(), e);
}
}
}
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