use of it.unibo.arces.wot.sepa.commons.exceptions.SEPANotExistsException in project SEPA by arces-wot.
the class SPUManager method unsubscribe.
// public Response unsubscribe(String sid, String gid) {
// logger.log(Level.getLevel("SPUManager"), "@unsubscribe " + sid + " " + gid);
// return internalUnsubscribe(sid, gid, true);
// }
// public void killSubscription(String sid, String gid) {
// logger.log(Level.getLevel("SPUManager"), "@killSubscription " + sid + " " + gid);
// internalUnsubscribe(sid, gid, false);
// }
public Response unsubscribe(String sid, String gid) {
// private Response internalUnsubscribe(String sid, String gid, boolean dep) {
// + " " + dep);
logger.log(Level.getLevel("SPUManager"), "@internalUnsubscribe " + sid + " " + gid);
try {
// Subscriber sub = Subscriptions.getSubscriber(sid);
//
// endOfProcessing(sub.getSPU());
//
// synchronized (activeSpus) {
// activeSpus.remove(sub.getSPU());
// }
Subscriptions.removeSubscriber(sid);
} catch (SEPANotExistsException e) {
logger.warn("@internalUnsubscribe SID not found: " + sid);
return new ErrorResponse(500, "sid_not_found", "Unregistering a not existing subscriber: " + sid);
}
// if (dep)
Dependability.onUnsubscribe(gid, sid);
return new UnsubscribeResponse(sid);
}
use of it.unibo.arces.wot.sepa.commons.exceptions.SEPANotExistsException in project SEPA by arces-wot.
the class Subscriptions method notifySubscribers.
public static synchronized void notifySubscribers(Notification notify) {
logger.log(Level.getLevel("subscriptions"), "@notifySubscribers");
String spuid = notify.getSpuid();
if (!spus.containsKey(spuid))
return;
HashSet<Subscriber> brokenSubscribers = new HashSet<Subscriber>();
for (Subscriber client : handlers.get(spuid)) {
// Dispatching events
Notification event = new Notification(client.getSID(), notify.getARBindingsResults(), client.nextSequence());
try {
client.notifyEvent(event);
} catch (SEPAProtocolException e) {
logger.error(e.getMessage());
if (logger.isTraceEnabled())
e.printStackTrace();
brokenSubscribers.add(client);
}
}
for (Subscriber client : brokenSubscribers) {
try {
removeSubscriber(client.getSID());
} catch (SEPANotExistsException e) {
logger.error(e.getMessage());
if (logger.isTraceEnabled())
e.printStackTrace();
}
}
}
Aggregations