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

Refactoring work.


git-svn-id: http://svn.igniterealtime.org/svn/repos/messenger/trunk@590 b35dd754-fafc-0310-a699-88a17e54d16e
parent 7a6e9f40
......@@ -24,6 +24,10 @@ import java.util.List;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;
import org.dom4j.QName;
import org.xmpp.packet.IQ;
import org.xmpp.packet.PacketError;
import org.xmpp.packet.Presence;
import org.xmpp.packet.JID;
/**
* A handler for the IQ packet with namespace http://jabber.org/protocol/muc#admin. This kind of
......@@ -68,7 +72,7 @@ public class IQAdminHandler {
*/
public void handleIQ(IQ packet, MUCRole role) throws ForbiddenException, ConflictException,
NotAllowedException {
IQ reply = packet.createResult();
IQ reply = IQ.createResultIQ(packet);
Element element = ((XMPPDOMFragment)packet.getChildFragment()).getRootElement();
// Analyze the action to perform based on the included element
......@@ -79,9 +83,9 @@ public class IQAdminHandler {
else {
// An unknown and possibly incorrect element was included in the query
// element so answer a BAD_REQUEST error
reply.setError(XMPPError.Code.BAD_REQUEST);
reply.setError(PacketError.Condition.bad_request);
}
if (reply.getRecipient() != null) {
if (reply.getTo() != null) {
// Send a reply only if the sender of the original packet was from a real JID. (i.e. not
// a packet generated locally)
router.route(reply);
......@@ -214,7 +218,7 @@ public class IQAdminHandler {
}
else {
// The client is modifying the list of moderators/members/participants/outcasts
String jid = null;
JID jid = null;
String nick;
String target = null;
boolean hasAffiliation = ((Element) itemsList.get(0)).attributeValue("affiliation") !=
......@@ -232,12 +236,12 @@ public class IQAdminHandler {
// jid could be of the form "full JID" or "bare JID" depending if we are
// going to change a role or an affiliation
if (hasJID) {
jid = item.attributeValue("jid");
jid = new JID(item.attributeValue("jid"));
}
else {
// Get the JID based on the requested nick
nick = item.attributeValue("nick");
jid = room.getOccupant(nick).getChatUser().getAddress().toStringPrep();
jid = room.getOccupant(nick).getChatUser().getAddress();
}
room.lock.writeLock().lock();
......@@ -288,13 +292,13 @@ public class IQAdminHandler {
if (MUCRole.MODERATOR != senderRole.getRole()) {
throw new ForbiddenException();
}
presences.add(room.kickOccupant(jid, senderRole.getChatUser()
.getAddress().toBareStringPrep(), item
.elementTextTrim("reason")));
presences.add(room.kickOccupant(jid,
senderRole.getChatUser().getAddress(),
item.elementTextTrim("reason")));
}
}
else {
reply.setError(XMPPError.Code.BAD_REQUEST);
reply.setError(PacketError.Condition.bad_request);
}
}
finally {
......
......@@ -34,6 +34,8 @@ import org.jivesoftware.util.Log;
import org.jivesoftware.messenger.*;
import org.jivesoftware.messenger.auth.UnauthorizedException;
import org.jivesoftware.messenger.handler.IQHandler;
import org.xmpp.packet.IQ;
import org.xmpp.packet.Presence;
/**
* This class is not an actual IQHandler since all the packets with namespace
......@@ -130,7 +132,7 @@ public class IQMUCRegisterHandler extends IQHandler {
return reply;
}
if (IQ.GET.equals(packet.getType())) {
if (IQ.Type.get == packet.getType()) {
reply = packet.createResult();
String nickname = room.getReservedNickname(packet.getSender().toBareStringPrep());
if (nickname != null) {
......@@ -148,7 +150,7 @@ public class IQMUCRegisterHandler extends IQHandler {
reply.setChildFragment(probeResult);
}
}
else if (IQ.SET.equals(packet.getType())) {
else if (IQ.Type.set == packet.getType()) {
try {
// Keep a registry of the updated presences
List<Presence> presences = new ArrayList<Presence>();
......
......@@ -203,7 +203,7 @@ public class MUCPersistenceManager {
// possible
if (!room.getRoomHistory().hasChangedSubject() && room.getSubject() != null &&
room.getSubject().length() > 0) {
room.getRoomHistory().addOldMessage(room.getRole().getRoleAddress().toStringPrep(),
room.getRoomHistory().addOldMessage(room.getRole().getRoleAddress().toString(),
null, room.getModificationDate(), room.getSubject(), null);
}
......@@ -449,7 +449,7 @@ public class MUCPersistenceManager {
loadedRoom.getSubject() != null &&
loadedRoom.getSubject().length() > 0) {
loadedRoom.getRoomHistory().addOldMessage(loadedRoom.getRole().getRoleAddress()
.toStringPrep(), null,
.toString(), null,
loadedRoom.getModificationDate(), loadedRoom.getSubject(), null);
}
}
......@@ -781,7 +781,7 @@ public class MUCPersistenceManager {
con = DbConnectionManager.getConnection();
pstmt = con.prepareStatement(ADD_CONVERSATION_LOG);
pstmt.setLong(1, entry.getRoomID());
pstmt.setString(2, entry.getSender().toStringPrep());
pstmt.setString(2, entry.getSender().toString());
pstmt.setString(3, entry.getNickname());
pstmt.setString(4, StringUtils.dateToMillis(entry.getDate()));
pstmt.setString(5, entry.getSubject());
......
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