Commit 4015cb93 authored by Matt Tucker's avatar Matt Tucker Committed by matt

Code cleanup.


git-svn-id: http://svn.igniterealtime.org/svn/repos/messenger/trunk@899 b35dd754-fafc-0310-a699-88a17e54d16e
parent b0791660
......@@ -13,7 +13,6 @@ package org.jivesoftware.messenger;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.jivesoftware.util.StringUtils;
import org.xmpp.packet.Packet;
import org.xmpp.packet.JID;
import org.xmpp.packet.Presence;
......@@ -56,7 +55,7 @@ public class ComponentManager {
* @param component the <code>Component</code> to register.
*/
public void addComponent(String jid, Component component) {
jid = validateJID(jid);
jid = new JID(jid).toBareJID();
components.put(jid, component);
// Check for potential interested users.
......@@ -69,7 +68,7 @@ public class ComponentManager {
* @param jid the jid mapped to the particular component.
*/
public void removeComponent(String jid) {
components.remove(validateJID(jid));
components.remove(new JID(jid).toBareJID());
}
/**
......@@ -80,18 +79,19 @@ public class ComponentManager {
* @return the component with the specified id.
*/
public Component getComponent(String jid) {
if (components.containsKey(validateJID(jid))) {
return components.get(validateJID(jid));
jid = new JID(jid).toBareJID();
if (components.containsKey(jid)) {
return components.get(jid);
}
else {
String serverName = StringUtils.parseServer(validateJID(jid));
String serverName = new JID(jid).getDomain();
int index = serverName.indexOf(".");
if (index != -1) {
String serviceName = serverName.substring(0, index);
jid = serviceName;
}
}
return components.get(validateJID(jid));
return components.get(jid);
}
/**
......@@ -118,11 +118,6 @@ public class ComponentManager {
}
}
private String validateJID(String jid) {
jid = jid.trim().toLowerCase();
return jid;
}
private void checkPresences() {
for (JID prober : presenceMap.keySet()) {
JID probee = presenceMap.get(prober);
......
......@@ -22,7 +22,6 @@ import org.jivesoftware.messenger.IQHandlerInfo;
import org.jivesoftware.messenger.XMPPServer;
import org.jivesoftware.messenger.handler.IQHandler;
import org.jivesoftware.messenger.auth.UnauthorizedException;
import org.jivesoftware.util.StringUtils;
import org.xmpp.packet.IQ;
import org.xmpp.packet.JID;
import org.xmpp.packet.PacketError;
......@@ -178,7 +177,7 @@ public class IQDiscoItemsHandler extends IQHandler implements ServerFeaturesProv
serverItems.add(element);
// Add the new item as a valid entity that could receive info and items disco requests
String host = StringUtils.parseServer(discoItem.getJID());
String host = new JID(discoItem.getJID()).getDomain();
infoHandler.setProvider(host, discoItem.getDiscoInfoProvider());
setProvider(host, discoItem.getDiscoItemsProvider());
}
......@@ -209,8 +208,7 @@ public class IQDiscoItemsHandler extends IQHandler implements ServerFeaturesProv
private DiscoItemsProvider getServerItemsProvider() {
DiscoItemsProvider discoItemsProvider = new DiscoItemsProvider() {
public Iterator<Element> getItems(String name, String node, JID senderJID)
throws UnauthorizedException {
public Iterator<Element> getItems(String name, String node, JID senderJID) {
return serverItems.iterator();
}
};
......
......@@ -871,96 +871,4 @@ public class StringUtils {
public static final String dateToMillis(Date date) {
return zeroPadString(Long.toString(date.getTime()), 15);
}
/**
* Returns the name portion of a XMPP address. For example, for the
* address "matt@example.org/Smack", "matt" would be returned. If no
* username is present in the address, the empty string will be returned.
*
* @param XMPPAddress the XMPP address.
* @return the name portion of the XMPP address.
*/
public static String parseName(String XMPPAddress) {
if (XMPPAddress == null) {
return null;
}
int atIndex = XMPPAddress.indexOf("@");
if (atIndex <= 0) {
return "";
}
else {
return XMPPAddress.substring(0, atIndex);
}
}
/**
* Returns the server portion of a XMPP address. For example, for the
* address "matt@example.org/Smack", "example.org" would be returned.
* If no server is present in the address, the empty string will be returned.
*
* @param XMPPAddress the XMPP address.
* @return the server portion of the XMPP address.
*/
public static String parseServer(String XMPPAddress) {
if (XMPPAddress == null) {
return null;
}
int atIndex = XMPPAddress.indexOf("@");
// If the String ends with '@', return the empty string.
if (atIndex + 1 > XMPPAddress.length()) {
return "";
}
int slashIndex = XMPPAddress.indexOf("/");
if (slashIndex > 0) {
return XMPPAddress.substring(atIndex + 1, slashIndex);
}
else {
return XMPPAddress.substring(atIndex + 1);
}
}
/**
* Returns the resource portion of a XMPP address. For example, for the
* address "matt@example.org/Smack", "Smack" would be returned. If no
* resource is present in the address, the empty string will be returned.
*
* @param XMPPAddress the XMPP address.
* @return the resource portion of the XMPP address.
*/
public static String parseResource(String XMPPAddress) {
if (XMPPAddress == null) {
return null;
}
int slashIndex = XMPPAddress.indexOf("/");
if (slashIndex + 1 > XMPPAddress.length() || slashIndex < 0) {
return "";
}
else {
return XMPPAddress.substring(slashIndex + 1);
}
}
/**
* Returns the XMPP address with any resource information removed. For example,
* for the address "matt@example.org/Smack", "matt@example.org" would
* be returned.
*
* @param XMPPAddress the XMPP address.
* @return the bare XMPP address without resource information.
*/
public static String parseBareAddress(String XMPPAddress) {
if (XMPPAddress == null) {
return null;
}
int slashIndex = XMPPAddress.indexOf("/");
if (slashIndex < 0) {
return XMPPAddress;
}
else if (slashIndex == 0) {
return "";
}
else {
return XMPPAddress.substring(0, slashIndex);
}
}
}
\ No newline at end of file
......@@ -56,7 +56,7 @@
int strategy = ParamUtils.getIntParameter(request,"strategy",-1);
int storeStrategy = ParamUtils.getIntParameter(request,"storeStrategy",-1);
double quota = ParamUtils.getIntParameter(request,"quota",0);
DecimalFormat format = new DecimalFormat("#0.0");
DecimalFormat format = new DecimalFormat("#0.00");
// Get the offline message manager
OfflineMessageStrategy manager = admin.getXMPPServer().getOfflineMessageStrategy();
......@@ -192,6 +192,11 @@ amount of space on a server. There are several options for handling offline mess
the policy that best suites your needs.
</p>
<p>
Current size of all offline message:
<b><%= format.format(OfflineMessageStore.getInstance().getSize()/1024.0/1024.0) %> MB</b>
</p>
<form action="offline-messages.jsp">
<fieldset>
......
......@@ -48,10 +48,10 @@
ConnectionProvider conProvider = new EmbeddedConnectionProvider();
DbConnectionManager.setConnectionProvider(conProvider);
if (testConnection(errors)) {
// update the sidebar status
// Update the sidebar status
session.setAttribute("jive.setup.sidebar.3","done");
session.setAttribute("jive.setup.sidebar.4","in_progress");
// redirect
// Redirect
response.sendRedirect("setup-admin-settings.jsp");
return;
}
......
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