Notifying client of delivery awaiting.
This commit is contained in:
@@ -34,10 +34,10 @@ public class DeliveryService {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean hasUndeliveredPackages(Player player) {
|
||||
public boolean hasUndeliveredPackages(String player) {
|
||||
_deliveryLock.readLock().lock();
|
||||
try {
|
||||
return _undeliveredDeliverables.containsKey(player.getName());
|
||||
return _undeliveredDeliverables.containsKey(player);
|
||||
} finally {
|
||||
_deliveryLock.readLock().unlock();
|
||||
}
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
package com.gempukku.lotro.server;
|
||||
|
||||
import com.gempukku.lotro.collection.DeliveryService;
|
||||
import com.gempukku.lotro.db.PlayerDAO;
|
||||
import com.gempukku.lotro.game.Player;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.ws.rs.WebApplicationException;
|
||||
import javax.ws.rs.core.Context;
|
||||
import javax.ws.rs.core.Response;
|
||||
@@ -14,6 +16,15 @@ public abstract class AbstractResource {
|
||||
@Context
|
||||
protected PlayerDAO _playerDao;
|
||||
|
||||
@Context
|
||||
protected DeliveryService _deliveryService;
|
||||
|
||||
protected final void processDeliveryServiceNotification(HttpServletRequest request, HttpServletResponse response) {
|
||||
String logged = getLoggedUser(request);
|
||||
if (logged != null && _deliveryService.hasUndeliveredPackages(logged))
|
||||
response.addHeader("Delivery-Service-Package", "true");
|
||||
}
|
||||
|
||||
protected final String getLoggedUser(HttpServletRequest request) {
|
||||
return (String) request.getSession().getAttribute("logged");
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.gempukku.lotro.server;
|
||||
|
||||
import com.gempukku.lotro.collection.DeliveryService;
|
||||
import com.gempukku.lotro.db.CollectionDAO;
|
||||
import com.gempukku.lotro.db.DeckDAO;
|
||||
import com.gempukku.lotro.db.LeagueDAO;
|
||||
@@ -24,8 +23,6 @@ public class AdminResource extends AbstractResource {
|
||||
@Context
|
||||
private CollectionDAO _collectionDao;
|
||||
@Context
|
||||
private DeliveryService _deliveryService;
|
||||
@Context
|
||||
private DeckDAO _deckDao;
|
||||
@Context
|
||||
private LeagueDAO _leagueDao;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.gempukku.lotro.server;
|
||||
|
||||
import com.gempukku.lotro.collection.DeliveryService;
|
||||
import com.gempukku.lotro.common.Side;
|
||||
import com.gempukku.lotro.db.CollectionDAO;
|
||||
import com.gempukku.lotro.db.vo.League;
|
||||
@@ -13,6 +12,7 @@ import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.ws.rs.*;
|
||||
import javax.ws.rs.core.Context;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
@@ -32,8 +32,6 @@ public class CollectionResource extends AbstractResource {
|
||||
@Context
|
||||
private CollectionDAO _collectionDao;
|
||||
@Context
|
||||
private DeliveryService _deliveryService;
|
||||
@Context
|
||||
private LotroCardBlueprintLibrary _library;
|
||||
@Context
|
||||
private LeagueService _leagueService;
|
||||
@@ -49,7 +47,8 @@ public class CollectionResource extends AbstractResource {
|
||||
@QueryParam("filter") String filter,
|
||||
@QueryParam("start") int start,
|
||||
@QueryParam("count") int count,
|
||||
@Context HttpServletRequest request) throws ParserConfigurationException {
|
||||
@Context HttpServletRequest request,
|
||||
@Context HttpServletResponse response) throws ParserConfigurationException {
|
||||
Player resourceOwner = getResourceOwnerSafely(request, participantId);
|
||||
|
||||
CardCollection collection = getCollection(resourceOwner, collectionType);
|
||||
@@ -89,6 +88,8 @@ public class CollectionResource extends AbstractResource {
|
||||
index++;
|
||||
}
|
||||
|
||||
processDeliveryServiceNotification(request, response);
|
||||
|
||||
return doc;
|
||||
}
|
||||
|
||||
@@ -138,7 +139,8 @@ public class CollectionResource extends AbstractResource {
|
||||
@PathParam("collectionType") String collectionType,
|
||||
@FormParam("participantId") String participantId,
|
||||
@FormParam("pack") String packId,
|
||||
@Context HttpServletRequest request) throws ParserConfigurationException {
|
||||
@Context HttpServletRequest request,
|
||||
@Context HttpServletResponse response) throws ParserConfigurationException {
|
||||
Player resourceOwner = getResourceOwnerSafely(request, participantId);
|
||||
|
||||
CardCollection collection = getCollection(resourceOwner, collectionType);
|
||||
@@ -181,6 +183,8 @@ public class CollectionResource extends AbstractResource {
|
||||
}
|
||||
}
|
||||
|
||||
processDeliveryServiceNotification(request, response);
|
||||
|
||||
return doc;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.ws.rs.*;
|
||||
import javax.ws.rs.core.Context;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
@@ -95,7 +96,8 @@ public class GameResource extends AbstractResource {
|
||||
@FormParam("participantId") String participantId,
|
||||
@FormParam("decisionId") Integer decisionId,
|
||||
@FormParam("decisionValue") String decisionValue,
|
||||
@Context HttpServletRequest request) throws ParserConfigurationException {
|
||||
@Context HttpServletRequest request,
|
||||
@Context HttpServletResponse response) throws ParserConfigurationException {
|
||||
Player resourceOwner = getResourceOwnerSafely(request, participantId);
|
||||
|
||||
LoggingThreadLocal.start();
|
||||
@@ -123,6 +125,8 @@ public class GameResource extends AbstractResource {
|
||||
|
||||
doc.appendChild(update);
|
||||
|
||||
processDeliveryServiceNotification(request, response);
|
||||
|
||||
return doc;
|
||||
} finally {
|
||||
LoggingThreadLocal.stop(decisionId != null);
|
||||
|
||||
@@ -10,6 +10,7 @@ import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.ws.rs.*;
|
||||
import javax.ws.rs.core.Context;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
@@ -29,7 +30,8 @@ public class HallResource extends AbstractResource {
|
||||
@Produces(MediaType.APPLICATION_XML)
|
||||
public Document getHall(
|
||||
@QueryParam("participantId") String participantId,
|
||||
@Context HttpServletRequest request) throws ParserConfigurationException {
|
||||
@Context HttpServletRequest request,
|
||||
@Context HttpServletResponse response) throws ParserConfigurationException {
|
||||
Player resourceOwner = getResourceOwnerSafely(request, participantId);
|
||||
|
||||
DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
|
||||
@@ -56,9 +58,10 @@ public class HallResource extends AbstractResource {
|
||||
hall.appendChild(formatElem);
|
||||
}
|
||||
|
||||
|
||||
doc.appendChild(hall);
|
||||
|
||||
processDeliveryServiceNotification(request, response);
|
||||
|
||||
return doc;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user