Changeset 1277:461b8da4b5fc
- Timestamp:
- 06/18/10 21:15:41 (3 years ago)
- Author:
- Thomas Gambet <tgambet@…>
- Branch:
- default
- Message:
-
implemented error messages observer_not_found and observer_internal_error
- Files:
-
Legend:
- Unmodified
- Added
- Removed
-
|
r1126
|
r1277
|
|
| 4 | 4 | package org.w3c.unicorn.request; |
| 5 | 5 | |
| | 6 | import java.io.FileNotFoundException; |
| 6 | 7 | import java.io.IOException; |
| | 8 | import java.io.InputStream; |
| 7 | 9 | import java.net.MalformedURLException; |
| 8 | 10 | import java.util.Hashtable; |
| 9 | 11 | import java.util.Map; |
| 10 | 12 | |
| | 13 | import org.w3c.unicorn.Framework; |
| 11 | 14 | import org.w3c.unicorn.contract.EnumInputMethod; |
| 12 | 15 | import org.w3c.unicorn.input.UploadInputModule; |
| … |
… |
|
| 92 | 95 | public Response doRequest() throws UnicornException { |
| 93 | 96 | logger.trace("doRequest"); |
| | 97 | String observerName = Framework.mapOfObserver.get(observerId).getName(sLang.split(",")[0]); |
| 94 | 98 | try { |
| 95 | 99 | aClientHttpRequest = new ClientHttpRequest(sURL); |
| … |
… |
|
| 108 | 112 | } |
| 109 | 113 | |
| 110 | | // TODO How to find the response content encoding here ? |
| 111 | | return ResponseFactory.getResponse(aClientHttpRequest.post(), responseType, sURL.toString(), null, observerId); |
| | 114 | InputStream stream = null; |
| | 115 | try { |
| | 116 | stream = aClientHttpRequest.post(); |
| | 117 | // TODO How to find the response content encoding here ? |
| | 118 | return ResponseFactory.getResponse(stream, responseType, sURL.toString(), null, observerId); |
| | 119 | } catch (FileNotFoundException e) { |
| | 120 | throw new UnicornException(Message.ERROR, "$message_observer_not_found", null, observerName); |
| | 121 | } catch (IOException e) { |
| | 122 | if (e.getMessage().contains("Server returned HTTP response code: 500")) |
| | 123 | throw new UnicornException(Message.ERROR, "$message_observer_internal_error", null, observerName); |
| | 124 | else |
| | 125 | throw e; |
| | 126 | } |
| 112 | 127 | |
| 113 | 128 | } catch (MalformedURLException e) { |