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());
}
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);
}
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);
}
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();
}
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;
}
Aggregations