use of de.janrufmonitor.service.commons.http.IRequester in project janrufmonitor by tbrandt77.
the class ClientDialerDialog method getLines.
private String[] getLines() {
IRequester r = this.getRequester(new GetDialExtensions());
IHttpResponse resp = r.request();
this.m_logger.info("GetExtensionsList returned " + resp.getCode());
if (resp.getCode() == 200) {
try {
String lines = new String(resp.getContent());
if (lines != null & lines.length() > 0) {
this.m_logger.info("GetExtensionsList returned " + lines);
return lines.split(",");
}
} catch (Exception e) {
m_logger.log(Level.SEVERE, e.getMessage(), e);
return null;
}
}
return null;
}
use of de.janrufmonitor.service.commons.http.IRequester in project janrufmonitor by tbrandt77.
the class Server method sendRequest.
private synchronized void sendRequest(IEvent event, IHttpRequest request) {
List clients = ClientRegistry.getInstance().getAllClients();
Client c = null;
for (int i = 0; i < clients.size(); i++) {
c = (Client) clients.get(i);
Object call = event.getData();
if (call != null && call instanceof ICall) {
IMsn msn = ((ICall) call).getMSN();
if (!SecurityManager.getInstance().isAllowedForMSN(c.getClientIP(), msn.getMSN()) || !SecurityManager.getInstance().isAllowedForMSN(c.getClientName(), msn.getMSN())) {
this.m_logger.info("Client " + c + " is blocked for MSN " + msn.getMSN() + ".");
continue;
}
}
if (this.isEventClient(c.getEvents(), event.getType())) {
this.m_logger.info("Sending event #" + event + " to client " + c + ".");
try {
if (request.getContent() != null)
c.setByteReceived(request.getContent().length);
IRequester r = null;
if (c.getClientName().trim().length() > 0)
r = RequesterFactory.getInstance().getRequester(c.getClientName(), c.getClientPort());
else
r = RequesterFactory.getInstance().getRequester(c.getClientIP(), c.getClientPort());
r.setRequest(request);
Thread s = new Thread(new SenderThread(r));
s.setName("JAM-" + SenderThread.class.getName() + "#" + i + "-Thread-(non-deamon)");
s.start();
} catch (Exception e) {
this.m_logger.severe(e.getMessage());
}
}
}
}
use of de.janrufmonitor.service.commons.http.IRequester in project janrufmonitor by tbrandt77.
the class HttpCallerManager method getCallers.
public ICallerList getCallers(IFilter[] filters, ISearchTerm[] searchTerms) {
if (!this.isConnected()) {
this.m_logger.warning("Client is not yet connected with the server.");
return this.getRuntime().getCallerFactory().createCallerList();
}
IRequester r = this.getRequester(new CallerListGetHandler(this.getCallerManager(), filters, searchTerms));
IHttpResponse resp = r.request();
String xml = this.getXmlContent(resp);
this.handleRequester(resp, r);
ICallerList l = XMLSerializer.toCallerList(xml);
if (l != null) {
this.addCallerManagerAttribute(l);
return l;
}
this.m_logger.warning("Callerlist from remote host was empty.");
return this.getRuntime().getCallerFactory().createCallerList();
}
use of de.janrufmonitor.service.commons.http.IRequester in project janrufmonitor by tbrandt77.
the class HttpCallerManager method setCaller.
public void setCaller(ICallerList callerList) {
if (!this.isConnected()) {
this.m_logger.warning("Client is not yet connected with the server.");
return;
}
IRequester r = null;
IHttpResponse resp = null;
r = this.getRequester(new CallerListSetHandler(callerList, this.getCallerManager()));
resp = r.request();
this.handleRequester(resp, r);
}
use of de.janrufmonitor.service.commons.http.IRequester in project janrufmonitor by tbrandt77.
the class HttpCallerManager method updateCaller.
public void updateCaller(ICaller caller) {
ICallerList cl = this.getRuntime().getCallerFactory().createCallerList();
cl.add(caller);
if (!this.isConnected()) {
this.m_logger.warning("Client is not yet connected with the server.");
return;
}
IRequester r = null;
IHttpResponse resp = null;
r = this.getRequester(new CallerListUpdateHandler(cl, this.getCallerManager()));
resp = r.request();
this.handleRequester(resp, r);
ImageCache.getInstance().remove(caller.getPhoneNumber().getTelephoneNumber());
}
Aggregations