Fixing error messages.
This commit is contained in:
@@ -35,6 +35,11 @@
|
||||
<artifactId>commons-dbcp</artifactId>
|
||||
<version>1.4</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sun.jersey</groupId>
|
||||
<artifactId>jersey-server</artifactId>
|
||||
<version>1.8</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>servlet-api</artifactId>
|
||||
|
||||
@@ -2,6 +2,8 @@ package com.gempukku.lotro.chat;
|
||||
|
||||
import com.gempukku.lotro.game.GatheringChatRoomListener;
|
||||
|
||||
import javax.ws.rs.WebApplicationException;
|
||||
import javax.ws.rs.core.Response;
|
||||
import java.util.*;
|
||||
|
||||
public class ChatRoomMediator {
|
||||
@@ -23,7 +25,7 @@ public class ChatRoomMediator {
|
||||
|
||||
public synchronized List<ChatMessage> joinUser(String playerId) {
|
||||
if (_allowedPlayers != null && !_allowedPlayers.contains(playerId))
|
||||
return null;
|
||||
throw new WebApplicationException(Response.Status.FORBIDDEN);
|
||||
|
||||
GatheringChatRoomListener value = new GatheringChatRoomListener();
|
||||
_listeners.put(playerId, value);
|
||||
@@ -33,11 +35,11 @@ public class ChatRoomMediator {
|
||||
|
||||
public synchronized List<ChatMessage> getPendingMessages(String playerId) {
|
||||
if (_allowedPlayers != null && !_allowedPlayers.contains(playerId))
|
||||
return null;
|
||||
throw new WebApplicationException(Response.Status.FORBIDDEN);
|
||||
|
||||
GatheringChatRoomListener gatheringChatRoomListener = _listeners.get(playerId);
|
||||
if (gatheringChatRoomListener == null)
|
||||
return null;
|
||||
throw new WebApplicationException(Response.Status.NOT_FOUND);
|
||||
return gatheringChatRoomListener.consumeMessages();
|
||||
}
|
||||
|
||||
@@ -46,12 +48,11 @@ public class ChatRoomMediator {
|
||||
_listeners.remove(playerId);
|
||||
}
|
||||
|
||||
public synchronized boolean sendMessage(String playerId, String message) {
|
||||
public synchronized void sendMessage(String playerId, String message) {
|
||||
if (_allowedPlayers != null && !_allowedPlayers.contains(playerId))
|
||||
return false;
|
||||
throw new WebApplicationException(Response.Status.FORBIDDEN);
|
||||
|
||||
_chatRoom.postMessage(playerId, message);
|
||||
return true;
|
||||
}
|
||||
|
||||
public synchronized void cleanup() {
|
||||
|
||||
@@ -12,6 +12,8 @@ import com.gempukku.lotro.logic.timing.DefaultLotroGame;
|
||||
import com.gempukku.lotro.logic.timing.GameResultListener;
|
||||
import com.gempukku.lotro.logic.vo.LotroDeck;
|
||||
|
||||
import javax.ws.rs.WebApplicationException;
|
||||
import javax.ws.rs.core.Response;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||
|
||||
@@ -293,10 +295,10 @@ public class LotroGameMediator {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean processCommunicationChannel(Player player, int channelNumber, ParticipantCommunicationVisitor visitor) {
|
||||
public void processCommunicationChannel(Player player, int channelNumber, ParticipantCommunicationVisitor visitor) {
|
||||
String playerName = player.getName();
|
||||
if (_noSpectators && !_playersPlaying.contains(playerName))
|
||||
return false;
|
||||
throw new WebApplicationException(Response.Status.FORBIDDEN);
|
||||
|
||||
_readLock.lock();
|
||||
try {
|
||||
@@ -326,13 +328,12 @@ public class LotroGameMediator {
|
||||
} finally {
|
||||
_readLock.unlock();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean singupUserForGame(Player player, ParticipantCommunicationVisitor visitor) {
|
||||
public void singupUserForGame(Player player, ParticipantCommunicationVisitor visitor) {
|
||||
String playerName = player.getName();
|
||||
if (_noSpectators && !_playersPlaying.contains(playerName))
|
||||
return false;
|
||||
throw new WebApplicationException(Response.Status.FORBIDDEN);
|
||||
|
||||
_readLock.lock();
|
||||
try {
|
||||
@@ -358,7 +359,6 @@ public class LotroGameMediator {
|
||||
} finally {
|
||||
_readLock.unlock();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void startClocksForUsersPendingDecision() {
|
||||
|
||||
@@ -40,8 +40,6 @@ public class ChatResource extends AbstractResource {
|
||||
sendError(Response.Status.NOT_FOUND);
|
||||
|
||||
List<ChatMessage> chatMessages = chatRoom.joinUser(resourceOwner.getName());
|
||||
if (chatMessages == null)
|
||||
sendError(Response.Status.FORBIDDEN);
|
||||
Collection<String> usersInRoom = chatRoom.getUsersInRoom();
|
||||
|
||||
DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
|
||||
@@ -71,14 +69,11 @@ public class ChatResource extends AbstractResource {
|
||||
if (messages != null) {
|
||||
for (String message : messages) {
|
||||
if (message != null && message.trim().length() > 0)
|
||||
if (!chatRoom.sendMessage(resourceOwner.getName(), StringEscapeUtils.escapeHtml(message)))
|
||||
sendError(Response.Status.FORBIDDEN);
|
||||
chatRoom.sendMessage(resourceOwner.getName(), StringEscapeUtils.escapeHtml(message));
|
||||
}
|
||||
}
|
||||
|
||||
List<ChatMessage> chatMessages = chatRoom.getPendingMessages(resourceOwner.getName());
|
||||
if (chatMessages == null)
|
||||
sendError(Response.Status.FORBIDDEN);
|
||||
|
||||
Collection<String> usersInRoom = chatRoom.getUsersInRoom();
|
||||
|
||||
|
||||
@@ -67,8 +67,7 @@ public class GameResource extends AbstractResource {
|
||||
Document doc = documentBuilder.newDocument();
|
||||
Element gameState = doc.createElement("gameState");
|
||||
|
||||
if (!gameMediator.singupUserForGame(resourceOwner, new SerializationVisitor(doc, gameState)))
|
||||
sendError(Response.Status.FORBIDDEN);
|
||||
gameMediator.singupUserForGame(resourceOwner, new SerializationVisitor(doc, gameState));
|
||||
|
||||
doc.appendChild(gameState);
|
||||
return doc;
|
||||
@@ -159,8 +158,7 @@ public class GameResource extends AbstractResource {
|
||||
Document doc = documentBuilder.newDocument();
|
||||
Element update = doc.createElement("update");
|
||||
|
||||
if (!gameMediator.processCommunicationChannel(resourceOwner, channelNumber, new SerializationVisitor(doc, update)))
|
||||
sendError(Response.Status.FORBIDDEN);
|
||||
gameMediator.processCommunicationChannel(resourceOwner, channelNumber, new SerializationVisitor(doc, update));
|
||||
|
||||
doc.appendChild(update);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user