Search in sources :

Example 11 with IRequester

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;
}
Also used : GetDialExtensions(de.janrufmonitor.service.client.request.handler.GetDialExtensions) IRequester(de.janrufmonitor.service.commons.http.IRequester) UnsupportedEncodingException(java.io.UnsupportedEncodingException) IHttpResponse(de.janrufmonitor.service.commons.http.IHttpResponse)

Example 12 with IRequester

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());
            }
        }
    }
}
Also used : ICall(de.janrufmonitor.framework.ICall) List(java.util.List) IRequester(de.janrufmonitor.service.commons.http.IRequester) IMsn(de.janrufmonitor.framework.IMsn)

Example 13 with IRequester

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();
}
Also used : CallerListGetHandler(de.janrufmonitor.service.client.request.handler.CallerListGetHandler) ICallerList(de.janrufmonitor.framework.ICallerList) IRequester(de.janrufmonitor.service.commons.http.IRequester) IHttpResponse(de.janrufmonitor.service.commons.http.IHttpResponse)

Example 14 with IRequester

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);
}
Also used : CallerListSetHandler(de.janrufmonitor.service.client.request.handler.CallerListSetHandler) IRequester(de.janrufmonitor.service.commons.http.IRequester) IHttpResponse(de.janrufmonitor.service.commons.http.IHttpResponse)

Example 15 with IRequester

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());
}
Also used : ICallerList(de.janrufmonitor.framework.ICallerList) IRequester(de.janrufmonitor.service.commons.http.IRequester) CallerListUpdateHandler(de.janrufmonitor.service.client.request.handler.CallerListUpdateHandler) IHttpResponse(de.janrufmonitor.service.commons.http.IHttpResponse)

Aggregations

IRequester (de.janrufmonitor.service.commons.http.IRequester)21 IHttpResponse (de.janrufmonitor.service.commons.http.IHttpResponse)14 UnknownHostException (java.net.UnknownHostException)4 ICallerList (de.janrufmonitor.framework.ICallerList)3 GetDialExtensions (de.janrufmonitor.service.client.request.handler.GetDialExtensions)3 IHttpRequest (de.janrufmonitor.service.commons.http.IHttpRequest)3 IOException (java.io.IOException)3 CallerListGetHandler (de.janrufmonitor.service.client.request.handler.CallerListGetHandler)2 GetImageHandler (de.janrufmonitor.service.client.request.handler.GetImageHandler)2 FileNotFoundException (java.io.FileNotFoundException)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)2 MalformedURLException (java.net.MalformedURLException)2 Message (de.janrufmonitor.exception.Message)1 ICall (de.janrufmonitor.framework.ICall)1 ICallList (de.janrufmonitor.framework.ICallList)1 ICaller (de.janrufmonitor.framework.ICaller)1 IMsn (de.janrufmonitor.framework.IMsn)1 ClientHandler (de.janrufmonitor.service.client.http.simple.ClientHandler)1 CallListCountGetHandler (de.janrufmonitor.service.client.request.handler.CallListCountGetHandler)1 CallListGetHandler (de.janrufmonitor.service.client.request.handler.CallListGetHandler)1