Commit aed17322 authored by Matt Tucker's avatar Matt Tucker Committed by matt

Backed out of JDK 1.6 changes -- they won't work on 1.5 :(

git-svn-id: http://svn.igniterealtime.org/svn/repos/wildfire/trunk@6070 b35dd754-fafc-0310-a699-88a17e54d16e
parent 6e226c7f
......@@ -11,12 +11,8 @@
package org.jivesoftware.database;
import org.jivesoftware.util.Log;
import java.sql.*;
import java.util.Map;
import java.util.Properties;
import java.lang.reflect.Method;
/**
* An implementation of the Connection interface that wraps an underlying
......@@ -190,200 +186,4 @@ public abstract class AbstractConnection implements Connection {
throws SQLException {
return connection.prepareStatement(sql, columnNames);
}
// JDK 1.6 Methods. We must handle these using reflection so that the code will compile on
// both JDK 1.6 and 1.5.
public Clob createClob() throws SQLException {
try {
Method method = connection.getClass().getMethod("createClob", new Class[] {});
return (Clob)method.invoke(connection);
}
catch (Exception e) {
if (e instanceof SQLException) {
throw (SQLException)e;
}
// Simply log reflection exceptions.
Log.error(e);
return null;
}
}
public Blob createBlob() throws SQLException {
try {
Method method = connection.getClass().getMethod("createBlob", new Class[] {});
return (Blob)method.invoke(connection);
}
catch (Exception e) {
if (e instanceof SQLException) {
throw (SQLException)e;
}
// Simply log reflection exceptions.
Log.error(e);
return null;
}
}
public NClob createNClob() throws SQLException {
try {
Method method = connection.getClass().getMethod("createNClob", new Class[] {});
return (NClob)method.invoke(connection);
}
catch (Exception e) {
if (e instanceof SQLException) {
throw (SQLException)e;
}
// Simply log reflection exceptions.
Log.error(e);
return null;
}
}
public SQLXML createSQLXML() throws SQLException {
try {
Method method = connection.getClass().getMethod("createSQLXML", new Class[] {});
return (SQLXML)method.invoke(connection);
}
catch (Exception e) {
if (e instanceof SQLException) {
throw (SQLException)e;
}
// Simply log reflection exceptions.
Log.error(e);
return null;
}
}
public boolean isValid(int timeout) throws SQLException {
try {
Method method = connection.getClass().getMethod("createClob", Integer.class);
return (Boolean)method.invoke(connection, timeout);
}
catch (Exception e) {
if (e instanceof SQLException) {
throw (SQLException)e;
}
// Simply log reflection exceptions.
Log.error(e);
return false;
}
}
public void setClientInfo(String name, String value) throws SQLClientInfoException {
try {
Method method = connection.getClass().getMethod("setClientInfo", String.class, String.class);
method.invoke(connection, name, value);
}
catch (Exception e) {
if (e instanceof SQLException) {
throw (SQLClientInfoException)e;
}
// Simply log reflection exceptions.
Log.error(e);
}
}
public void setClientInfo(Properties properties) throws SQLClientInfoException {
try {
Method method = connection.getClass().getMethod("setClientInfo", Properties.class);
method.invoke(connection, properties);
}
catch (Exception e) {
if (e instanceof SQLException) {
throw (SQLClientInfoException)e;
}
// Simply log reflection exceptions.
Log.error(e);
}
}
public String getClientInfo(String name) throws SQLException {
try {
Method method = connection.getClass().getMethod("getClientInfo", String.class);
return (String)method.invoke(connection, name);
}
catch (Exception e) {
if (e instanceof SQLException) {
throw (SQLException)e;
}
// Simply log reflection exceptions.
Log.error(e);
return null;
}
}
public Properties getClientInfo() throws SQLException {
try {
Method method = connection.getClass().getMethod("getClientInfo", new Class[] {});
return (Properties)method.invoke(connection);
}
catch (Exception e) {
if (e instanceof SQLException) {
throw (SQLException)e;
}
// Simply log reflection exceptions.
Log.error(e);
return null;
}
}
public Array createArrayOf(String typeName, Object[] elements) throws SQLException {
try {
Method method = connection.getClass().getMethod("createArrayOf", String.class, Object[].class);
return (Array)method.invoke(connection, typeName, elements);
}
catch (Exception e) {
if (e instanceof SQLException) {
throw (SQLException)e;
}
// Simply log reflection exceptions.
Log.error(e);
return null;
}
}
public Struct createStruct(String typeName, Object[] attributes) throws SQLException {
try {
Method method = connection.getClass().getMethod("createStruct", String.class, Object[].class);
return (Struct)method.invoke(connection, typeName, attributes);
}
catch (Exception e) {
if (e instanceof SQLException) {
throw (SQLException)e;
}
// Simply log reflection exceptions.
Log.error(e);
return null;
}
}
public <T> T unwrap(Class<T> iface) throws SQLException {
try {
Method method = connection.getClass().getMethod("unwrap", Class.class);
return (T)method.invoke(connection, iface);
}
catch (Exception e) {
if (e instanceof SQLException) {
throw (SQLException)e;
}
// Simply log reflection exceptions.
Log.error(e);
return null;
}
}
public boolean isWrapperFor(Class<?> iface) throws SQLException {
try {
Method method = connection.getClass().getMethod("isWrapperFor", Class.class);
return (Boolean)method.invoke(connection, iface);
}
catch (Exception e) {
if (e instanceof SQLException) {
throw (SQLException)e;
}
// Simply log reflection exceptions.
Log.error(e);
return false;
}
}
}
\ No newline at end of file
......@@ -509,224 +509,4 @@ public abstract class CallableStatementWrapper extends StatementWrapper
public ParameterMetaData getParameterMetaData() throws SQLException {
return cstmt.getParameterMetaData();
}
// JDK 1.6 Methods. Not actually implemented. TODO: use refelection to handle.
public RowId getRowId(int parameterIndex) throws SQLException {
throw new UnsupportedOperationException();
}
public RowId getRowId(String parameterName) throws SQLException {
throw new UnsupportedOperationException();
}
public void setRowId(String parameterName, RowId x) throws SQLException {
throw new UnsupportedOperationException();
}
public void setNString(String parameterName, String value) throws SQLException {
throw new UnsupportedOperationException();
}
public void setNCharacterStream(String parameterName, Reader value, long length)
throws SQLException
{
throw new UnsupportedOperationException();
}
public void setNClob(String parameterName, NClob value) throws SQLException {
throw new UnsupportedOperationException();
}
public void setClob(String parameterName, Reader reader, long length) throws SQLException {
throw new UnsupportedOperationException();
}
public void setBlob(String parameterName, InputStream inputStream, long length)
throws SQLException
{
throw new UnsupportedOperationException();
}
public void setNClob(String parameterName, Reader reader, long length) throws SQLException {
throw new UnsupportedOperationException();
}
public NClob getNClob(int parameterIndex) throws SQLException {
throw new UnsupportedOperationException();
}
public NClob getNClob(String parameterName) throws SQLException {
throw new UnsupportedOperationException();
}
public void setSQLXML(String parameterName, SQLXML xmlObject) throws SQLException {
throw new UnsupportedOperationException();
}
public SQLXML getSQLXML(int parameterIndex) throws SQLException {
throw new UnsupportedOperationException();
}
public SQLXML getSQLXML(String parameterName) throws SQLException {
throw new UnsupportedOperationException();
}
public String getNString(int parameterIndex) throws SQLException {
throw new UnsupportedOperationException();
}
public String getNString(String parameterName) throws SQLException {
throw new UnsupportedOperationException();
}
public Reader getNCharacterStream(int parameterIndex) throws SQLException {
throw new UnsupportedOperationException();
}
public Reader getNCharacterStream(String parameterName) throws SQLException {
throw new UnsupportedOperationException();
}
public Reader getCharacterStream(int parameterIndex) throws SQLException {
throw new UnsupportedOperationException();
}
public Reader getCharacterStream(String parameterName) throws SQLException {
throw new UnsupportedOperationException();
}
public void setBlob(String parameterName, Blob x) throws SQLException {
throw new UnsupportedOperationException();
}
public void setClob(String parameterName, Clob x) throws SQLException {
throw new UnsupportedOperationException();
}
public void setAsciiStream(String parameterName, InputStream x, long length)
throws SQLException
{
throw new UnsupportedOperationException();
}
public void setBinaryStream(String parameterName, InputStream x, long length)
throws SQLException
{
throw new UnsupportedOperationException();
}
public void setCharacterStream(String parameterName, Reader reader, long length)
throws SQLException
{
throw new UnsupportedOperationException();
}
public void setAsciiStream(String parameterName, InputStream x) throws SQLException {
throw new UnsupportedOperationException();
}
public void setBinaryStream(String parameterName, InputStream x) throws SQLException {
throw new UnsupportedOperationException();
}
public void setCharacterStream(String parameterName, Reader reader) throws SQLException {
throw new UnsupportedOperationException();
}
public void setNCharacterStream(String parameterName, Reader value) throws SQLException {
throw new UnsupportedOperationException();
}
public void setClob(String parameterName, Reader reader) throws SQLException {
throw new UnsupportedOperationException();
}
public void setBlob(String parameterName, InputStream inputStream) throws SQLException {
throw new UnsupportedOperationException();
}
public void setNClob(String parameterName, Reader reader) throws SQLException {
throw new UnsupportedOperationException();
}
public void setRowId(int parameterIndex, RowId x) throws SQLException {
throw new UnsupportedOperationException();
}
public void setNString(int parameterIndex, String value) throws SQLException {
throw new UnsupportedOperationException();
}
public void setNCharacterStream(int parameterIndex, Reader value, long length)
throws SQLException
{
throw new UnsupportedOperationException();
}
public void setNClob(int parameterIndex, NClob value) throws SQLException {
throw new UnsupportedOperationException();
}
public void setClob(int parameterIndex, Reader reader, long length) throws SQLException {
throw new UnsupportedOperationException();
}
public void setBlob(int parameterIndex, InputStream inputStream, long length)
throws SQLException
{
throw new UnsupportedOperationException();
}
public void setNClob(int parameterIndex, Reader reader, long length) throws SQLException {
throw new UnsupportedOperationException();
}
public void setSQLXML(int parameterIndex, SQLXML xmlObject) throws SQLException {
throw new UnsupportedOperationException();
}
public void setAsciiStream(int parameterIndex, InputStream x, long length) throws SQLException {
throw new UnsupportedOperationException();
}
public void setBinaryStream(int parameterIndex, InputStream x, long length)
throws SQLException
{
throw new UnsupportedOperationException();
}
public void setCharacterStream(int parameterIndex, Reader reader, long length)
throws SQLException
{
throw new UnsupportedOperationException();
}
public void setAsciiStream(int parameterIndex, InputStream x) throws SQLException {
throw new UnsupportedOperationException();
}
public void setBinaryStream(int parameterIndex, InputStream x) throws SQLException {
throw new UnsupportedOperationException();
}
public void setCharacterStream(int parameterIndex, Reader reader) throws SQLException {
throw new UnsupportedOperationException();
}
public void setNCharacterStream(int parameterIndex, Reader value) throws SQLException {
throw new UnsupportedOperationException();
}
public void setClob(int parameterIndex, Reader reader) throws SQLException {
throw new UnsupportedOperationException();
}
public void setBlob(int parameterIndex, InputStream inputStream) throws SQLException {
throw new UnsupportedOperationException();
}
public void setNClob(int parameterIndex, Reader reader) throws SQLException {
throw new UnsupportedOperationException();
}
}
\ No newline at end of file
}
......@@ -184,86 +184,4 @@ public abstract class PreparedStatementWrapper extends StatementWrapper
public ParameterMetaData getParameterMetaData() throws SQLException {
return pstmt.getParameterMetaData();
}
// JDK 1.6 Methods. Not actually implemented. TODO: use refelection to handle.
public void setRowId(int parameterIndex, RowId x) throws SQLException {
throw new UnsupportedOperationException();
}
public void setNString(int parameterIndex, String value) throws SQLException {
throw new UnsupportedOperationException();
}
public void setNCharacterStream(int parameterIndex, Reader value, long length)
throws SQLException
{
throw new UnsupportedOperationException();
}
public void setNClob(int parameterIndex, NClob value) throws SQLException {
throw new UnsupportedOperationException();
}
public void setClob(int parameterIndex, Reader reader, long length) throws SQLException {
throw new UnsupportedOperationException();
}
public void setBlob(int parameterIndex, InputStream inputStream, long length)
throws SQLException
{
throw new UnsupportedOperationException();
}
public void setNClob(int parameterIndex, Reader reader, long length) throws SQLException {
throw new UnsupportedOperationException();
}
public void setSQLXML(int parameterIndex, SQLXML xmlObject) throws SQLException {
throw new UnsupportedOperationException();
}
public void setAsciiStream(int parameterIndex, InputStream x, long length) throws SQLException {
throw new UnsupportedOperationException();
}
public void setBinaryStream(int parameterIndex, InputStream x, long length)
throws SQLException
{
throw new UnsupportedOperationException();
}
public void setCharacterStream(int parameterIndex, Reader reader, long length)
throws SQLException
{
throw new UnsupportedOperationException();
}
public void setAsciiStream(int parameterIndex, InputStream x) throws SQLException {
throw new UnsupportedOperationException();
}
public void setBinaryStream(int parameterIndex, InputStream x) throws SQLException {
throw new UnsupportedOperationException();
}
public void setCharacterStream(int parameterIndex, Reader reader) throws SQLException {
throw new UnsupportedOperationException();
}
public void setNCharacterStream(int parameterIndex, Reader value) throws SQLException {
throw new UnsupportedOperationException();
}
public void setClob(int parameterIndex, Reader reader) throws SQLException {
throw new UnsupportedOperationException();
}
public void setBlob(int parameterIndex, InputStream inputStream) throws SQLException {
throw new UnsupportedOperationException();
}
public void setNClob(int parameterIndex, Reader reader) throws SQLException {
throw new UnsupportedOperationException();
}
}
\ No newline at end of file
}
......@@ -43,6 +43,13 @@
<h1>
Presence Plugin Changelog
</h1>
<p><b>1.4.0</b> -- July ??, 2006</p>
<ul>
<li>The administrator can now set custom values for the presence text.</li>
<li>Updated default presence images.</li>
<li>Added URL information to admin console page.</li>
</ul>
<p><b>1.3.3</b> -- November 03, 2006</p>
<ul>
......
......@@ -73,6 +73,8 @@ presence.jar file over the existing file.</p>
The presence plugin can be configured via the Wildfire Admin Console.
Use the configuration page to specify whether presence information should be available
to anyone or restricted to authorized users (users which have presence subscriptions).
The status message for unavailable users can also be changed from the default of
&quot;Unavailable&quot;.
<h2>Using the Plugin</h2>
......@@ -165,6 +167,15 @@ custom images that should be used to display the user's presence:</p>
</form>
</ul>
<p>This example requests the status text of the presence of a user in text format:</p>
<ul>
<form>
<textarea cols=65 rows=3 wrap=virtual>http://example.com:9090/plugins/presence/status?jid=jsmith@example.com&type=text
</textarea>
</form>
</ul>
<p><b>Working With Firewalls</b></p>
<p>Because the presence plugin runs within the Wildfire admin console web container, users
......
......@@ -142,6 +142,28 @@ public class PresencePlugin implements Plugin, Component {
JiveGlobals.setProperty("plugin.presence.public", presencesPublic ? "true" : "false");
}
/**
* Returns the status message for the unavailable presence. This setting allows
* a different string to be used for the status on this presence which is
* "Unavailable" by default.
*
* @return the status message for the unavailable presence.
*/
public String getUnavailableStatus() {
return JiveGlobals.getProperty("plugin.presence.unavailable.status", "Unavailable");
}
/**
* Sets the status message for the unavailable presence. This setting allows
* a different string to be used for the status on this presence which is
* "Unavailable" by default.
*
* @param statusMessage the status message for the unavailable presence.
*/
public void setUnavailableStatus(String statusMessage) {
JiveGlobals.setProperty("plugin.presence.unavailable.status", statusMessage);
}
/**
* Returns the presence of the requested user or <tt>null</tt> if the user is offline. If
* presences are not public then the user presence will be returned if and only if the sender
......
......@@ -61,12 +61,12 @@ public class PresenceStatusServlet extends HttpServlet {
xmlProvider = new XMLPresenceProvider();
imageProvider = new ImagePresenceProvider(this);
textProvider = new TextPresenceProvider();
available = loadResource("/images/user-green-16x16.gif");
away = loadResource("/images/user-yellow-16x16.gif");
chat = loadResource("/images/user-green-16x16.gif");
dnd = loadResource("/images/user-red-16x16.gif");
offline = loadResource("/images/user-clear-16x16.gif");
xa = loadResource("/images/user-yellow-16x16.gif");
available = loadResource("/plugins/presence/images/user-green-16x16.gif");
away = loadResource("/plugins/presence/images/user-yellow-16x16.gif");
chat = loadResource("/plugins/presence/images/user-green-16x16.gif");
dnd = loadResource("/plugins/presence/images/user-red-16x16.gif");
offline = loadResource("/plugins/presence/images/user-clear-16x16.gif");
xa = loadResource("/plugins/presence/images/user-yellow-16x16.gif");
// Exclude this servlet from requering the user to login
AuthCheckFilter.addExclude("presence/status");
}
......
......@@ -2,12 +2,9 @@
* $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.
* Copyright (C) 1999-2005 Jive Software. All rights reserved.
* This software is the proprietary information of Jive Software. Use is subject to license terms.
*/
package org.jivesoftware.wildfire.plugin.presence;
import org.xmpp.packet.Presence;
......@@ -16,6 +13,7 @@ import org.xmpp.packet.PacketError;
import org.jivesoftware.wildfire.XMPPServer;
import org.jivesoftware.wildfire.user.User;
import org.jivesoftware.wildfire.user.UserNotFoundException;
import org.jivesoftware.util.JiveGlobals;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
......@@ -46,10 +44,12 @@ class TextPresenceProvider extends PresenceInfoProvider {
if (status != null) {
presence.setStatus(status);
}
else {
presence.setStatus(JiveGlobals.getProperty("plugin.presence.unavailable.status",
"Unavailable"));
}
}
catch (UserNotFoundException e) {
// Ignore.
}
catch (UserNotFoundException e) {}
presence.setFrom(targetJID);
}
out.println(presence.getStatus());
......@@ -66,15 +66,11 @@ class TextPresenceProvider extends PresenceInfoProvider {
try {
presence.setFrom(new JID(request.getParameter("jid")));
}
catch (Exception e) {
// Ignore.
}
catch (Exception e) {}
try {
presence.setTo(new JID(request.getParameter("req_jid")));
}
catch (Exception e) {
// Ignore.
}
catch (Exception e) {}
out.println(presence.getStatus());
out.flush();
}
......
......@@ -14,6 +14,7 @@ package org.jivesoftware.wildfire.plugin.presence;
import org.jivesoftware.wildfire.XMPPServer;
import org.jivesoftware.wildfire.user.User;
import org.jivesoftware.wildfire.user.UserNotFoundException;
import org.jivesoftware.util.JiveGlobals;
import org.xmpp.packet.JID;
import org.xmpp.packet.PacketError;
import org.xmpp.packet.Presence;
......@@ -47,6 +48,10 @@ class XMLPresenceProvider extends PresenceInfoProvider {
if (status != null) {
presence.setStatus(status);
}
else {
presence.setStatus(JiveGlobals.getProperty("plugin.presence.unavailable.status",
"Unavailable"));
}
}
catch (UserNotFoundException e) {}
presence.setFrom(targetJID);
......
......@@ -8,16 +8,23 @@
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jstl/fmt_rt" prefix="fmt" %>
<% // Get parameters
<%
PresencePlugin plugin = (PresencePlugin)XMPPServer.getInstance().getPluginManager().getPlugin("presence");
// Get parameters
boolean save = request.getParameter("save") != null;
boolean success = request.getParameter("success") != null;
boolean presencePublic = ParamUtils.getBooleanParameter(request, "presencePublic");
String unavailableStatus = ParamUtils.getParameter(request, "presenceUnavailableStatus", false);
if (unavailableStatus == null) {
unavailableStatus = plugin.getUnavailableStatus();
}
PresencePlugin plugin = (PresencePlugin)XMPPServer.getInstance().getPluginManager().getPlugin("presence");
// Handle a save
if (save) {
plugin.setPresencePublic(presencePublic);
plugin.setUnavailableStatus(unavailableStatus);
response.sendRedirect("presence-service.jsp?success=true");
return;
}
......@@ -27,11 +34,29 @@
<html>
<head>
<title>Presence Service Properties</title>
<title>Presence Service</title>
<meta name="pageID" content="presence-service"/>
</head>
<body>
<div class="information">
<%
String serverName = XMPPServer.getInstance().getServerInfo().getName();
int port = JiveGlobals.getXMLProperty("adminConsole.port", -1);
int securePort = JiveGlobals.getXMLProperty("adminConsole.securePort", -1);
boolean secureOnly = (port == -1);
%>
Presence Service URL:<br>
<tt><%= secureOnly?"https":"http"%>://<%=serverName%>:<%= secureOnly?securePort:port%>/plugins/presence/status</tt>
<br><br>
Example:<br>
<tt><%= secureOnly?"https":"http"%>://<%=serverName%>:<%= secureOnly?securePort:port%>/plugins/presence/status?jid=admin@<%=serverName%></tt>
</div>
<p>
Use the form below to configure user presence visibility. By default, user
presence should only be visible to those users that are authorized.<br>
......@@ -86,6 +111,21 @@ presence should only be visible to those users that are authorized.<br>
</div>
</fieldset>
<br>
<fieldset>
<legend>Plain Text 'Unavailable' Status Message</legend>
<div>
<p>
In &quot;text&quot; mode the status message for unavailable users is &quot;Unavailable&quot;
by default. It is possible to change the unavailable status message by setting this property.
</p>
<p>
<input type="text" name="presenceUnavailableStatus" value="<%= unavailableStatus %>">
</p>
</div>
</fieldset>
<br><br>
<input type="submit" value="Save Properties">
......
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