Omaha #3107 added timeout handling logic for leader transfer verification

Former-commit-id: 294a489ba547bf90df9d6b6a5107c8993c5b8333
This commit is contained in:
Brian Clements 2014-05-09 15:43:46 -05:00
parent b334038a28
commit 7b7bc5be97
4 changed files with 32 additions and 12 deletions

View file

@ -24,7 +24,9 @@ import java.util.Map;
import java.util.Map.Entry;
import java.util.concurrent.ConcurrentHashMap;
import org.apache.commons.lang.StringUtils;
import org.jivesoftware.smack.ConnectionConfiguration;
import org.jivesoftware.smack.SmackConfiguration;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.filter.PacketTypeFilter;
@ -115,6 +117,7 @@ import com.raytheon.uf.viz.collaboration.comm.provider.user.VenueParticipant;
* moved listeners to own classes, reworked connect/register listeners/login order
* Apr 15, 2014 2822 bclement added pubsub owner subscriptions provider registration
* Apr 23, 2014 2822 bclement added resource name and getCollaborationVersion()
* May 09, 2014 3107 bclement added ability for packet timeout to be set via system properties
*
* </pre>
*
@ -176,13 +179,20 @@ public class CollaborationConnection implements IEventPublisher {
private ClientAuthManager authManager;
private static boolean COMPRESS = true;
static {
try {
final String compressionProperty = "collaboration.compression";
if (System.getProperty(compressionProperty) != null) {
COMPRESS = Boolean.getBoolean(compressionProperty);
}
String customTimeout = System
.getProperty("collaboration.packet.timeout");
if (!StringUtils.isBlank(customTimeout)
&& StringUtils.isNumeric(customTimeout)) {
SmackConfiguration.setPacketReplyTimeout(Integer
.parseInt(customTimeout));
}
} catch (Exception e) {
// must not have permission to access system properties. ignore and
// use default.

View file

@ -49,6 +49,7 @@ import com.raytheon.uf.common.xmpp.ext.ChangeAffiliationExtension;
* ------------ ---------- ----------- --------------------------
* Feb 18, 2014 2751 bclement Initial creation
* Apr 15, 2014 2822 bclement added getAllSubscriptions()
* May 09, 2014 3107 bclement added clarifying comment to sendAffiliationPacket()
*
* </pre>
*
@ -73,6 +74,7 @@ public class PubSubOperations {
public static void sendAffiliationPacket(XMPPConnection conn,
ChangeAffiliationExtension affiliation) throws XMPPException {
PubSub packet = createOwnerPacket(conn, affiliation, IQ.Type.SET);
/* this needs to be sync to get any errors back from server */
SyncPacketSend.getReply(conn, packet);
}

View file

@ -103,6 +103,7 @@ import com.raytheon.uf.viz.collaboration.comm.provider.user.VenueParticipant;
* Apr 22, 2014 2903 bclement added connection test to closePubSub() method
* Apr 23, 2014 2822 bclement added formatInviteAddress()
* Apr 29, 2014 3061 bclement added createInviteMessage()
* May 09, 2014 3107 bclement default to trust transfer event when verify errors out
*
* </pre>
*
@ -476,7 +477,17 @@ public class SharedDisplaySession extends VenueSession implements
private boolean handleLeaderChange(LeaderChangeEvent event) {
VenueParticipant newLeader = event.getNewLeader();
boolean rval;
if (!isRoomOwner(newLeader)) {
try {
rval = isRoomOwner(newLeader);
} catch (XMPPException e) {
log.error("Problem verifying room ownership for " + newLeader, e);
/*
* likely that the transfer leader event is authentic, returning
* false on a valid leader transfer event would cause problems
*/
rval = true;
}
if (!rval) {
log.info("Invalid leader change event: " + newLeader
+ " is not an owner of the room");
rval = false;

View file

@ -110,6 +110,7 @@ import com.raytheon.uf.viz.collaboration.comm.provider.user.VenueParticipant;
* Apr 22, 2014 2903 bclement added connection test to close method
* Apr 23, 2014 2822 bclement added formatInviteAddress()
* Apr 29, 2014 3061 bclement moved invite payload to shared display session
* May 09, 2014 3107 bclement removed catch from isRoomOwner() so callers know about errors
*
*
* </pre>
@ -945,19 +946,15 @@ public class VenueSession extends BaseSession implements IVenueSession {
/**
* @param p
* @return true if participant is an owner of the chat room
* @throws XMPPException
*/
protected boolean isRoomOwner(VenueParticipant p) {
protected boolean isRoomOwner(VenueParticipant p) throws XMPPException {
boolean rval = false;
try {
for (Affiliate aff : muc.getOwners()) {
if (aff.getNick().equals(p.getHandle())) {
rval = true;
break;
}
for (Affiliate aff : muc.getOwners()) {
if (aff.getNick().equals(p.getHandle())) {
rval = true;
break;
}
} catch (XMPPException e) {
log.error("Problem verifying room ownership for participant: " + p,
e);
}
return rval;
}