Commit 8bf3ea6a authored by Matt Tucker's avatar Matt Tucker Committed by matt

Use constant for delay info formatting.

git-svn-id: http://svn.igniterealtime.org/svn/repos/wildfire/trunk@5980 b35dd754-fafc-0310-a699-88a17e54d16e
parent 85e29834
...@@ -29,8 +29,15 @@ public class JiveConstants { ...@@ -29,8 +29,15 @@ public class JiveConstants {
/** /**
* Date/time format for use by SimpleDateFormat. The format conforms to * Date/time format for use by SimpleDateFormat. The format conforms to
* <a href="http://www.jabber.org/jeps/jep-0082.html">JEP-0082</a>, which defines * <a href="http://www.xmpp.org/extensions/xep-0082.html">XEP-0082</a>, which defines
* a unified date/time format for XMPP. * a unified date/time format for XMPP.
*/ */
public static final String XMPP_DATETIME_FORMAT = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"; public static final String XMPP_DATETIME_FORMAT = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'";
/**
* Date/time format for use by SimpleDateFormat. The format conforms to the format
* defined in <a href="http://www.xmpp.org/extensions/xep-0091.html">XEP-0091</a>,
* a specialized date format for historical XMPP usage.
*/
public static final String XMPP_DELAY_DATETIME_FORMAT = "yyyyMMdd'T'HH:mm:ss";
} }
\ No newline at end of file
...@@ -89,7 +89,8 @@ public class OfflineMessageStore extends BasicModule implements UserEventListene ...@@ -89,7 +89,8 @@ public class OfflineMessageStore extends BasicModule implements UserEventListene
*/ */
public OfflineMessageStore() { public OfflineMessageStore() {
super("Offline Message Store"); super("Offline Message Store");
dateFormat = FastDateFormat.getInstance("yyyyMMdd'T'HH:mm:ss", TimeZone.getTimeZone("UTC")); dateFormat = FastDateFormat.getInstance(JiveConstants.XMPP_DELAY_DATETIME_FORMAT,
TimeZone.getTimeZone("UTC"));
sizeCache = CacheManager.initializeCache("Offline Message Size", "offlinemessage", sizeCache = CacheManager.initializeCache("Offline Message Size", "offlinemessage",
1024 * 100, JiveConstants.HOUR * 12); 1024 * 100, JiveConstants.HOUR * 12);
} }
......
...@@ -17,6 +17,7 @@ import org.dom4j.QName; ...@@ -17,6 +17,7 @@ import org.dom4j.QName;
import org.jivesoftware.wildfire.IQHandlerInfo; import org.jivesoftware.wildfire.IQHandlerInfo;
import org.jivesoftware.wildfire.disco.ServerFeaturesProvider; import org.jivesoftware.wildfire.disco.ServerFeaturesProvider;
import org.jivesoftware.util.FastDateFormat; import org.jivesoftware.util.FastDateFormat;
import org.jivesoftware.util.JiveConstants;
import org.xmpp.packet.IQ; import org.xmpp.packet.IQ;
import java.text.DateFormat; import java.text.DateFormat;
...@@ -46,12 +47,13 @@ import java.util.TimeZone; ...@@ -46,12 +47,13 @@ import java.util.TimeZone;
*/ */
public class IQTimeHandler extends IQHandler implements ServerFeaturesProvider { public class IQTimeHandler extends IQHandler implements ServerFeaturesProvider {
// todo Make display text match the locale of user (xml:lang support) // todo: Make display text match the locale of user (xml:lang support)
private static final DateFormat DATE_FORMAT = DateFormat.getDateInstance(DateFormat.MEDIUM); private static final DateFormat DATE_FORMAT = DateFormat.getDateInstance(DateFormat.MEDIUM);
private static final DateFormat TIME_FORMAT = DateFormat.getTimeInstance(DateFormat.LONG); private static final DateFormat TIME_FORMAT = DateFormat.getTimeInstance(DateFormat.LONG);
// UTC and not JEP-0082 time format is used as per the JEP-0090 specification. // UTC and not JEP-0082 time format is used as per the JEP-0090 specification.
private static final FastDateFormat UTC_FORMAT = FastDateFormat private static final FastDateFormat UTC_FORMAT =
.getInstance("yyyyMMdd'T'HH:mm:ss", TimeZone.getTimeZone("GMT+0")); FastDateFormat.getInstance(JiveConstants.XMPP_DELAY_DATETIME_FORMAT,
TimeZone.getTimeZone("UTC"));
private Element responseElement; private Element responseElement;
private IQHandlerInfo info; private IQHandlerInfo info;
......
...@@ -23,6 +23,7 @@ import java.util.TimeZone; ...@@ -23,6 +23,7 @@ import java.util.TimeZone;
import org.jivesoftware.wildfire.muc.spi.MUCRoleImpl; import org.jivesoftware.wildfire.muc.spi.MUCRoleImpl;
import org.jivesoftware.util.Log; import org.jivesoftware.util.Log;
import org.jivesoftware.util.JiveConstants; import org.jivesoftware.util.JiveConstants;
import org.jivesoftware.util.FastDateFormat;
import org.dom4j.Element; import org.dom4j.Element;
import org.xmpp.packet.Message; import org.xmpp.packet.Message;
...@@ -41,9 +42,10 @@ import org.xmpp.packet.Message; ...@@ -41,9 +42,10 @@ import org.xmpp.packet.Message;
public class HistoryRequest { public class HistoryRequest {
private static final DateFormat formatter = new SimpleDateFormat(JiveConstants.XMPP_DATETIME_FORMAT); private static final DateFormat formatter = new SimpleDateFormat(JiveConstants.XMPP_DATETIME_FORMAT);
private static final DateFormat delayedFormatter = new SimpleDateFormat("yyyyMMdd'T'HH:mm:ss"); private static final DateFormat delayedFormatter = new SimpleDateFormat(
JiveConstants.XMPP_DELAY_DATETIME_FORMAT);
static { static {
delayedFormatter.setTimeZone(TimeZone.getTimeZone("GMT+0")); delayedFormatter.setTimeZone(TimeZone.getTimeZone("UTC"));
formatter.setTimeZone(TimeZone.getTimeZone("UTC")); formatter.setTimeZone(TimeZone.getTimeZone("UTC"));
} }
......
...@@ -14,6 +14,7 @@ package org.jivesoftware.wildfire.muc; ...@@ -14,6 +14,7 @@ package org.jivesoftware.wildfire.muc;
import org.dom4j.Element; import org.dom4j.Element;
import org.jivesoftware.wildfire.user.UserNotFoundException; import org.jivesoftware.wildfire.user.UserNotFoundException;
import org.jivesoftware.util.FastDateFormat; import org.jivesoftware.util.FastDateFormat;
import org.jivesoftware.util.JiveConstants;
import org.xmpp.packet.JID; import org.xmpp.packet.JID;
import org.xmpp.packet.Message; import org.xmpp.packet.Message;
...@@ -31,7 +32,7 @@ import java.util.TimeZone; ...@@ -31,7 +32,7 @@ import java.util.TimeZone;
public final class MUCRoomHistory { public final class MUCRoomHistory {
private static final FastDateFormat UTC_FORMAT = FastDateFormat private static final FastDateFormat UTC_FORMAT = FastDateFormat
.getInstance("yyyyMMdd'T'HH:mm:ss", TimeZone.getTimeZone("GMT+0")); .getInstance(JiveConstants.XMPP_DELAY_DATETIME_FORMAT, TimeZone.getTimeZone("UTC"));
private MUCRoom room; private MUCRoom room;
...@@ -60,7 +61,7 @@ public final class MUCRoomHistory { ...@@ -60,7 +61,7 @@ public final class MUCRoomHistory {
} }
} }
Message packetToAdd = (Message) packet.createCopy(); Message packetToAdd = packet.createCopy();
// Check if the room has changed its configuration // Check if the room has changed its configuration
if (isNonAnonymousRoom != room.canAnyoneDiscoverJID()) { if (isNonAnonymousRoom != room.canAnyoneDiscoverJID()) {
...@@ -79,6 +80,7 @@ public final class MUCRoomHistory { ...@@ -79,6 +80,7 @@ public final class MUCRoomHistory {
delayElement.addAttribute("from", role.getChatUser().getAddress().toString()); delayElement.addAttribute("from", role.getChatUser().getAddress().toString());
} }
catch (UserNotFoundException e) { catch (UserNotFoundException e) {
// Ignore.
} }
} }
else { else {
...@@ -101,6 +103,7 @@ public final class MUCRoomHistory { ...@@ -101,6 +103,7 @@ public final class MUCRoomHistory {
.toString()); .toString());
} }
catch (UserNotFoundException e) { catch (UserNotFoundException e) {
// Ignore.
} }
} }
else { else {
......
...@@ -13,10 +13,7 @@ package org.jivesoftware.wildfire.muc.spi; ...@@ -13,10 +13,7 @@ package org.jivesoftware.wildfire.muc.spi;
import org.dom4j.DocumentHelper; import org.dom4j.DocumentHelper;
import org.dom4j.Element; import org.dom4j.Element;
import org.jivesoftware.util.FastDateFormat; import org.jivesoftware.util.*;
import org.jivesoftware.util.JiveGlobals;
import org.jivesoftware.util.LocaleUtils;
import org.jivesoftware.util.Log;
import org.jivesoftware.wildfire.*; import org.jivesoftware.wildfire.*;
import org.jivesoftware.wildfire.auth.UnauthorizedException; import org.jivesoftware.wildfire.auth.UnauthorizedException;
import org.jivesoftware.wildfire.container.BasicModule; import org.jivesoftware.wildfire.container.BasicModule;
...@@ -62,7 +59,7 @@ public class MultiUserChatServerImpl extends BasicModule implements MultiUserCha ...@@ -62,7 +59,7 @@ public class MultiUserChatServerImpl extends BasicModule implements MultiUserCha
ServerItemsProvider, DiscoInfoProvider, DiscoItemsProvider, RoutableChannelHandler { ServerItemsProvider, DiscoInfoProvider, DiscoItemsProvider, RoutableChannelHandler {
private static final FastDateFormat dateFormatter = FastDateFormat private static final FastDateFormat dateFormatter = FastDateFormat
.getInstance("yyyyMMdd'T'HH:mm:ss", TimeZone.getTimeZone("GMT+0")); .getInstance(JiveConstants.XMPP_DELAY_DATETIME_FORMAT, TimeZone.getTimeZone("UTC"));
/** /**
* Statistics keys * Statistics keys
......
...@@ -23,6 +23,7 @@ package org.xmpp.forms; ...@@ -23,6 +23,7 @@ package org.xmpp.forms;
import org.dom4j.Element; import org.dom4j.Element;
import org.dom4j.QName; import org.dom4j.QName;
import org.jivesoftware.util.FastDateFormat; import org.jivesoftware.util.FastDateFormat;
import org.jivesoftware.util.JiveConstants;
import org.xmpp.packet.PacketExtension; import org.xmpp.packet.PacketExtension;
import java.text.ParseException; import java.text.ParseException;
...@@ -50,9 +51,11 @@ import java.util.*; ...@@ -50,9 +51,11 @@ import java.util.*;
*/ */
public class DataForm extends PacketExtension { public class DataForm extends PacketExtension {
private static final SimpleDateFormat UTC_FORMAT = new SimpleDateFormat("yyyyMMdd'T'HH:mm:ss"); private static final SimpleDateFormat UTC_FORMAT = new SimpleDateFormat(
JiveConstants.XMPP_DELAY_DATETIME_FORMAT);
private static final FastDateFormat FAST_UTC_FORMAT = private static final FastDateFormat FAST_UTC_FORMAT =
FastDateFormat.getInstance("yyyyMMdd'T'HH:mm:ss", TimeZone.getTimeZone("UTC")); FastDateFormat.getInstance(JiveConstants.XMPP_DELAY_DATETIME_FORMAT,
TimeZone.getTimeZone("UTC"));
/** /**
* Element name of the packet extension. * Element name of the packet extension.
...@@ -65,7 +68,7 @@ public class DataForm extends PacketExtension { ...@@ -65,7 +68,7 @@ public class DataForm extends PacketExtension {
public static final String NAMESPACE = "jabber:x:data"; public static final String NAMESPACE = "jabber:x:data";
static { static {
UTC_FORMAT.setTimeZone(TimeZone.getTimeZone("GMT+0")); UTC_FORMAT.setTimeZone(TimeZone.getTimeZone("UTC"));
// Register that DataForms uses the jabber:x:data namespace // Register that DataForms uses the jabber:x:data namespace
registeredExtensions.put(QName.get(ELEMENT_NAME, NAMESPACE), DataForm.class); registeredExtensions.put(QName.get(ELEMENT_NAME, NAMESPACE), DataForm.class);
} }
......
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