Search in sources :

Example 11 with IHttpResponse

use of de.janrufmonitor.service.commons.http.IHttpResponse 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)

Example 12 with IHttpResponse

use of de.janrufmonitor.service.commons.http.IHttpResponse in project janrufmonitor by tbrandt77.

the class HttpCallManager method removeCalls.

public void removeCalls(ICallList calllist) {
    if (!this.isConnected()) {
        this.m_logger.warning("Client is not yet connected with the server.");
        return;
    }
    IRequester r = this.getRequester(new CallListRemoveHandler(calllist, this.getCallManager()));
    IHttpResponse resp = r.request();
    this.handleRequester(resp, r);
}
Also used : IRequester(de.janrufmonitor.service.commons.http.IRequester) CallListRemoveHandler(de.janrufmonitor.service.client.request.handler.CallListRemoveHandler) IHttpResponse(de.janrufmonitor.service.commons.http.IHttpResponse)

Example 13 with IHttpResponse

use of de.janrufmonitor.service.commons.http.IHttpResponse in project janrufmonitor by tbrandt77.

the class HttpCallManager method getCallCount.

public int getCallCount(IFilter[] filters, ISearchTerm[] searchTerms) {
    if (!this.isConnected()) {
        this.m_logger.warning("Client is not yet connected with the server.");
        return 0;
    }
    IRequester r = this.getRequester(new CallListCountGetHandler(this.getCallManager(), filters, searchTerms));
    IHttpResponse resp = r.request();
    String xml = this.getXmlContent(resp);
    this.handleRequester(resp, r);
    if (xml.length() > 0) {
        return Integer.parseInt(xml);
    }
    return super.getCallCount(filters);
}
Also used : CallListCountGetHandler(de.janrufmonitor.service.client.request.handler.CallListCountGetHandler) IRequester(de.janrufmonitor.service.commons.http.IRequester) IHttpResponse(de.janrufmonitor.service.commons.http.IHttpResponse)

Example 14 with IHttpResponse

use of de.janrufmonitor.service.commons.http.IHttpResponse in project janrufmonitor by tbrandt77.

the class ClientDialerDialog method okPressed.

protected void okPressed() {
    if (dialBox != null) {
        String dial = PhonenumberAnalyzer.getInstance(PIMRuntime.getInstance()).toCallable(dialBox.getText());
        // added 2010/03/06: check for dial prefix for outgoing calls
        if (this.getRuntime().getConfigManagerFactory().getConfigManager().getProperty(IJAMConst.GLOBAL_NAMESPACE, IJAMConst.GLOBAL_DIAL_PREFIX).length() > 0) {
            if (this.m_logger.isLoggable(Level.INFO))
                this.m_logger.info("Using dial prefix: " + this.getRuntime().getConfigManagerFactory().getConfigManager().getProperty(IJAMConst.GLOBAL_NAMESPACE, IJAMConst.GLOBAL_DIAL_PREFIX));
            dial = this.getRuntime().getConfigManagerFactory().getConfigManager().getProperty(IJAMConst.GLOBAL_NAMESPACE, IJAMConst.GLOBAL_DIAL_PREFIX).trim() + dial;
        }
        if (dial.trim().length() > 0) {
            String text = getI18nManager().getString("ui.jface.application.dialer.ClientDialerCommand", "success", "description", getLanguage());
            text = StringUtils.replaceString(text, "{%1}", dial);
            String text2 = this.getI18nManager().getString("ui.jface.application.dialer.ClientDialerCommand", "success", "label", this.getLanguage());
            text2 = StringUtils.replaceString(text2, "{%1}", line.getText());
            if (MessageDialog.openConfirm(new Shell(DisplayManager.getDefaultDisplay()), text2, text)) {
                String selectedTapi = line.getText();
                ClientHandle th = (ClientHandle) handlemap.get(selectedTapi);
                if (th != null && th.getLine().length() > 0) {
                    // save the handle for next time selection
                    getRuntime().getConfigManagerFactory().getConfigManager().setProperty(NAMESPACE, "lineselection", selectedTapi);
                    getRuntime().getConfigManagerFactory().getConfigManager().saveConfiguration();
                    if (m_logger.isLoggable(Level.INFO)) {
                        m_logger.info("Selected Client handle: " + th.toString());
                    }
                    try {
                        IRequester r = this.getRequester(new Dial(dial, URLEncoder.encode(th.getLine(), "UTF-8")));
                        IHttpResponse resp = r.request();
                        if (resp.getCode() != 200) {
                            m_logger.severe("Invalid client call to server. Error code " + resp.getCode());
                        }
                    } catch (UnsupportedEncodingException e) {
                        m_logger.log(Level.SEVERE, e.getMessage(), e);
                    }
                } else {
                    m_logger.warning("Invalid Client line for outgoing call selected.");
                }
            }
        }
    }
    super.okPressed();
}
Also used : Dial(de.janrufmonitor.service.client.request.handler.Dial) Shell(org.eclipse.swt.widgets.Shell) UnsupportedEncodingException(java.io.UnsupportedEncodingException) IRequester(de.janrufmonitor.service.commons.http.IRequester) IHttpResponse(de.janrufmonitor.service.commons.http.IHttpResponse)

Example 15 with IHttpResponse

use of de.janrufmonitor.service.commons.http.IHttpResponse in project janrufmonitor by tbrandt77.

the class JakartaRequester method request.

public IHttpResponse request() {
    HttpClientParams params = new HttpClientParams();
    params.setParameter(HttpClientParams.RETRY_HANDLER, new DefaultHttpMethodRetryHandler(1, false));
    HttpClient client = new HttpClient(params);
    try {
        if (this.m_r instanceof Request) {
            HttpMethod m = null;
            byte[] result = null;
            if (this.m_r != null && this.m_r.getMethod().equalsIgnoreCase(Request.METHOD_POST)) {
                String url = "http://" + this.getServer() + ":" + this.getPort() + this.m_r.getURI();
                m = new PostMethod(url);
                if (this.m_r.getContent() != null) {
                    ((PostMethod) m).setRequestEntity(new ByteArrayRequestEntity(this.m_r.getContent()));
                // removed: 27.05.2005: changed to httpclient 3.0
                // ((PostMethod)m).setRequestBody(new ByteArrayInputStream(this.m_r.getContent()));
                // ((PostMethod)m).setRequestContentLength(this.m_r.getContent().length);
                }
                this.m_responseCode = client.executeMethod(m);
                if (this.m_responseCode == HttpStatus.SC_OK)
                    result = m.getResponseBody();
            }
            if (this.m_r != null && this.m_r.getMethod().equalsIgnoreCase(Request.METHOD_GET)) {
                String url = "http://" + this.getServer() + ":" + this.getPort() + this.m_r.getURI();
                m = new GetMethod(url);
                this.m_responseCode = client.executeMethod(m);
                if (this.m_responseCode == HttpStatus.SC_OK)
                    result = m.getResponseBody();
            }
            Response resp = new Response();
            Header[] headers = m.getResponseHeaders();
            for (int i = 0; i < headers.length; i++) {
                resp.setParameter(headers[i].getName(), headers[i].getValue());
            }
            resp.setCode(this.m_responseCode);
            resp.setContent(result);
            String debugEnabled = System.getProperty("jam.http.debug");
            if (debugEnabled != null && debugEnabled.equalsIgnoreCase("true")) {
                this.dump(this.m_r.toString());
                this.dump(resp.toString());
            }
            if (m != null)
                m.releaseConnection();
            return resp;
        }
    } catch (IOException ex) {
        this.m_responseCode = 0;
    } catch (Exception e) {
        this.m_responseCode = 0;
    }
    Response resp = new Response();
    resp.setCode(0);
    return resp;
}
Also used : PostMethod(org.apache.commons.httpclient.methods.PostMethod) DefaultHttpMethodRetryHandler(org.apache.commons.httpclient.DefaultHttpMethodRetryHandler) IMutableHttpRequest(de.janrufmonitor.service.commons.http.IMutableHttpRequest) IHttpRequest(de.janrufmonitor.service.commons.http.IHttpRequest) IOException(java.io.IOException) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException) IHttpResponse(de.janrufmonitor.service.commons.http.IHttpResponse) Header(org.apache.commons.httpclient.Header) HttpClient(org.apache.commons.httpclient.HttpClient) HttpClientParams(org.apache.commons.httpclient.params.HttpClientParams) GetMethod(org.apache.commons.httpclient.methods.GetMethod) HttpMethod(org.apache.commons.httpclient.HttpMethod) ByteArrayRequestEntity(org.apache.commons.httpclient.methods.ByteArrayRequestEntity)

Aggregations

IHttpResponse (de.janrufmonitor.service.commons.http.IHttpResponse)15 IRequester (de.janrufmonitor.service.commons.http.IRequester)14 ICallerList (de.janrufmonitor.framework.ICallerList)3 GetDialExtensions (de.janrufmonitor.service.client.request.handler.GetDialExtensions)3 CallerListGetHandler (de.janrufmonitor.service.client.request.handler.CallerListGetHandler)2 IOException (java.io.IOException)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)2 Message (de.janrufmonitor.exception.Message)1 ICallList (de.janrufmonitor.framework.ICallList)1 ICaller (de.janrufmonitor.framework.ICaller)1 CallListCountGetHandler (de.janrufmonitor.service.client.request.handler.CallListCountGetHandler)1 CallListGetHandler (de.janrufmonitor.service.client.request.handler.CallListGetHandler)1 CallListRemoveHandler (de.janrufmonitor.service.client.request.handler.CallListRemoveHandler)1 CallListSetHandler (de.janrufmonitor.service.client.request.handler.CallListSetHandler)1 CallerGetHandler (de.janrufmonitor.service.client.request.handler.CallerGetHandler)1 CallerListRemoveHandler (de.janrufmonitor.service.client.request.handler.CallerListRemoveHandler)1 CallerListSetHandler (de.janrufmonitor.service.client.request.handler.CallerListSetHandler)1 CallerListUpdateHandler (de.janrufmonitor.service.client.request.handler.CallerListUpdateHandler)1 Dial (de.janrufmonitor.service.client.request.handler.Dial)1 IHttpRequest (de.janrufmonitor.service.commons.http.IHttpRequest)1