Skip to content

Commit 786320c

Browse files
committed
Added ResourceException#resource attribute.
1 parent 9b35c77 commit 786320c

4 files changed

Lines changed: 57 additions & 78 deletions

File tree

build/tmpl/text/changes.txt

Lines changed: 37 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
1+
22
===========
3-
Changes log
3+
Changes log
44
===========
55

66
@version-full@ (@release-date@)
@@ -18,9 +18,12 @@ Changes log
1818
Reported and contributed by Ralph van Etten.
1919
- Enhancements
2020
- Added Request and response attributes to the ResourceException class.
21-
- ServerResource traces Exception in the doCatch method with SEVERE log
21+
- ServerResource traces Exception in the doCatch method with SEVERE log
2222
level, in case of 5xx errors.
2323
- Added Guice extension to GAE edition. Issue #1136.
24+
- API changes
25+
- Added ResourceException#resource attribute and ResourceException#getRequest()
26+
and ResourceException#getResponse() shortcut methods.
2427

2528
- 2.3.4 (07/16/2015)
2629
- Bugs fixed
@@ -32,20 +35,20 @@ Changes log
3235
- Bugs fixed
3336
- Redirector does not translate response's entity location reference.
3437
Issue #1069.
35-
- Fixed tunnelFilter. + symbol (%2b) converted incorrectly when media
38+
- Fixed tunnelFilter. + symbol (%2b) converted incorrectly when media
3639
query parameter is used. Issue #804.
3740
Reported by Rob Elsner.
38-
- Fixed never ending call when an exception happens while writing the
41+
- Fixed never ending call when an exception happens while writing the
3942
response's entity using the internal HTTP server connector.
4043
Issue #1061. Reported by Gernot Pansy.
4144
- Prevented insertion of query params into POST request for JAX-RS client.
4245
Issue #1072. Reported by Edouard Mercier.
43-
- Fixed NPE when OAuth refresh token request when no scope is provided.
46+
- Fixed NPE when OAuth refresh token request when no scope is provided.
4447
Issue #1080. Reported by Gernot Pansy.
4548
- Internal HTTP client doesn't fail anymore with null values in headers.
4649
- Improved robustness of Swagger translation code (import/export).
4750
- Fixed security scheme issue in RAML translator.
48-
51+
4952
- Enhancements
5053
- Allowed spaces in the values of the Java methods annotations. Issue #1099.
5154
- Added support for Chromium browser when extracting user agent info.
@@ -56,20 +59,20 @@ Changes log
5659
- Fix CORS header name Access-Control-Allow-Credentials. Issue #1030.
5760
- Fixed malformed JSON in the JsonpRepresentation.
5861
Reported by Wagner Correa Ramos.
59-
- When catching a 405 status, make sure to update allowed methods inside
62+
- When catching a 405 status, make sure to update allowed methods inside
6063
a ServerResource. Issue #1034.
6164
Reported by Jeremy Gustie.
6265
- Fixed wrong Reference.getRemainingPart(boolean decode). Issue #1041.
6366
Reported by Tal Liron.
64-
- Authorization header is not sent by GWT client, for authentication scheme other
67+
- Authorization header is not sent by GWT client, for authentication scheme other
6568
than HTTP Basic. Issue #1040.
6669
- Jetty client connector duplicates User-Agent header. Issue #1055.
6770
Reported by Charlie Mason.
68-
- Fixed Restlet JAX-RS encoding problem when using @FormParam annotation.
71+
- Fixed Restlet JAX-RS encoding problem when using @FormParam annotation.
6972
Issue #1038.
70-
- Fixed Tomcat shutdown due to TaskService that did not instantiate
73+
- Fixed Tomcat shutdown due to TaskService that did not instantiate
7174
threads as daemon threads. Issue #1053.
72-
- Made a public field private in JaxRs extension which lead some
75+
- Made a public field private in JaxRs extension which lead some
7376
containers to stop the application. Issue #1058.
7477
Reported by Constantin Gruber.
7578
- Fixed duplication of headers (jaxrs). Issues #944, #948.
@@ -79,14 +82,14 @@ Changes log
7982
HTTP method annotations such as @Get("json?param=val).
8083

8184
- Enhancements
82-
- Allowed to turn off header cleaning in Redirector for server-side
85+
- Allowed to turn off header cleaning in Redirector for server-side
8386
redirects. Issue #799.
8487
Suggested by Tal Liron.
8588
- Upgraded swagger-models library to 1.5.3-M1.
8689

8790
- 2.3.1 (02/03/2015)
8891
- Bugs fixed
89-
- Reintroduced registration by default of the internal HTTP server
92+
- Reintroduced registration by default of the internal HTTP server
9093
connectors in JEE edition.
9194
- FormDataSet not properly serializing text/plain files. Issue #1006.
9295
Reported by johnjaylward.
@@ -95,7 +98,7 @@ Changes log
9598
Reported by Philippe Perrault.
9699
- Reference scheme reverts to http when using https. Issue #998.
97100
Reported by Stephen C. Pope.
98-
- Fixed bug that prevented client code to properly consume error
101+
- Fixed bug that prevented client code to properly consume error
99102
responses #1004 and #1018.
100103
Reported by Philippe Perrault and spraguep.
101104

@@ -111,7 +114,7 @@ Changes log
111114
to the internal serialized status object.
112115
- JacksonRepresentation fields are now thread safe.
113116
Reported by Tim Peierls.
114-
- Removed XML serialization using Jackson extension from Android edition as
117+
- Removed XML serialization using Jackson extension from Android edition as
115118
it depends on classes not supported by Android SDK (issue #964).
116119
Reported by Ralph van Etten.
117120
- Fixed OutputRepresentation in the GAE edition (issue #954).
@@ -136,18 +139,18 @@ Changes log
136139
Usage of XML support in Spring extension is recommended instead.
137140
- Deprecated e4 extension.
138141
Usage of Guice or Spring extensions is recommended instead.
139-
- Deprecated JDBC extension.
142+
- Deprecated JDBC extension.
140143
Use a persistence technology such as Mybatis or Hibernate instead.
141144
- Deprecated JiBX and XStream extensions.
142145
Use an XML serialization technology such as Jackson instead.
143146
- Deprecated jSSLUtils, ROME, XDB extensions.
144147
Libraries not actively developed anymore.
145148
- Deprecated Apache HTTP Client and Simple extensions.
146149
Will be removed to favor lower-level network extensions such as
147-
Jetty and Netty, allowing more control at the Restlet API level.
150+
Jetty and Netty, allowing more control at the Restlet API level.
148151
- Deprecated SIP, WebDAV extensions.
149152
Will be removed to focus on Web APIs.
150-
153+
151154
- Misc
152155
- Removed the Tanuki's Java Service Wrapper library.
153156
- Removed the CDDL and LGPL licences, kept Apache License, Version 2.0 and
@@ -170,7 +173,7 @@ Changes log
170173

171174
- API changes
172175
- Deprecated protected LogService#debugging property.
173-
- Added Application#debugging Boolean property and a start message
176+
- Added Application#debugging Boolean property and a start message
174177
indicating in which mode your application is.
175178
- Added getName() and getDescription() methods in ServerResource for
176179
documentation purpose. Note that this could conflict with existing
@@ -179,7 +182,7 @@ Changes log
179182
- Bugs fixed
180183
- Prevent potential security issue with Directory class.
181184
Contributed by Andrew Hughes.
182-
185+
183186
- Misc
184187
- Remove the outdated example based on the O'Reilly's book
185188
"RESTful Web Services" and the related db4o dependency.
@@ -188,7 +191,7 @@ Changes log
188191
- 2.3 Milestone 5 (11/07/2014)
189192
- Enhancements
190193
- Added support of GWT 2.7. Contributed by Koen Maes.
191-
- Enhanced introspection of Restlet and JAX-RS based applications in
194+
- Enhanced introspection of Restlet and JAX-RS based applications in
192195
conjunction with Swagger and Raml annotations.
193196
- Added APISpark agent service.
194197

@@ -200,12 +203,12 @@ Changes log
200203

201204
- 2.3 Milestone 4 (10/31/2014)
202205
- Enhancements
203-
- Unified the HTTP client connector parameters (socket connection to 15s,
204-
idle socket to 60s, socket stop to 60s, max connections per host to 10,
206+
- Unified the HTTP client connector parameters (socket connection to 15s,
207+
idle socket to 60s, socket stop to 60s, max connections per host to 10,
205208
max total connections to 20). Suggested by Kristoffer Gronowski.
206209
- Upgraded Jackson to version 2.4.3.
207210
- Jackson representation now ignore empty value (null or empty collections)
208-
by default in the JSON/XML/CSV/YAML produced, leading to more compact
211+
by default in the JSON/XML/CSV/YAML produced, leading to more compact
209212
representations.
210213
- Fixed log level (issue #777). Reported by Marcus NL.
211214

@@ -229,15 +232,15 @@ Changes log
229232
- Added RAML support in dedicated extension.
230233

231234
- Enhancements
232-
- Added targetRef support to templates, allow reference variables to
235+
- Added targetRef support to templates, allow reference variables to
233236
resolve to the full reference (issue #935).
234237
Contributed by Jeremy Gustie.
235238
- Updated agent.properties file with recent Opera user agent signature.
236239
- Added Resource#toRepresentation(Object, MediaType) convenience method.
237240
- Added ConverterService#toRepresentation(Object, MediaType) convenience method.
238241
- Added ConverterService#toRepresentation(Object, Variant) convenience method.
239-
- Added static Resource#toInteger, toFloat, toByte, toLong, toDouble, toBoolean
240-
methods accepting 'null' string values to facilitate the processing of path
242+
- Added static Resource#toInteger, toFloat, toByte, toLong, toDouble, toBoolean
243+
methods accepting 'null' string values to facilitate the processing of path
241244
variables and query parameters.
242245
- Renamed StatusService methods from getRepresentation(...) and getStatus(...) to
243246
toRepresentation(...) and toStatus(...), added throwable parameters to allow
@@ -249,12 +252,12 @@ Changes log
249252
NOTE: implementation is in progress.
250253
- StatusService.toStatus(Throwable, ...) methods now support @Status annotations
251254
to set the proper code.
252-
255+
253256
- Bugs fixed
254-
- ObjectRepresentation wasn't closing a Decoder in case reading exceptions occured.
257+
- ObjectRepresentation wasn't closing a Decoder in case reading exceptions occured.
255258
- ServerResource#doCatch() method wasn't invoking StatusService to set the error
256259
representation if empty.
257-
- Fixed potential NPE in odata extension when schema ComplexType in a
260+
- Fixed potential NPE in odata extension when schema ComplexType in a
258261
document does not declare a schema attribute (issue #932).
259262
- Uncaught exceptions may cause LogFilter to fail, with dire consequences.
260263
Issue #931. Reported and contributed by Tal Liron.
@@ -268,15 +271,15 @@ Changes log
268271
it to APISpark.com PaaS for online and intuive documentation. Added user guide
269272
page to describe the process and parameters. API contract can be created or
270273
updated (replaced) remotely.
271-
274+
272275
- Enhancements
273276
- Added HTTPS support to Jetty connector. Issue #793.
274277
Contributed by Tal Liron.
275278
- ServletWarEntity and ZipEntryEntity ignore the timeToLive parameter. Issue #866.
276279
Reported and contributed by Jeremy Gustie.
277280
- ServletWarEntity is limited to file system modification dates. Issue #868.
278281
Reported and contributed by Jeremy Gustie.
279-
282+
280283
- Bugs fixed
281284
- Added copy of Servlet request parameters to the Restlet request attributes. Issue #741.
282285
Reported by Steve Rowe and contributed by Jeremy Gustie.
@@ -304,7 +307,7 @@ Changes log
304307
- Added initial APISpark extension. Issue #875.
305308
- Added Jetty client for HTTP and HTTPS. Issue #512.
306309
Contributed by Tal Liron.
307-
310+
308311
- Enhancements
309312
- Upgraded project to Java 7. Issue #874.
310313
- Upgraded Jetty connector to version 9.1.3. Issue #793.

libraries/org.eclipse.jetty_9.2/.classpath

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<classpath>
33
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
44
<classpathentry exported="true" kind="lib" path="org.eclipse.jetty.client.jar"/>
5-
<classpathentry exported="true" kind="lib" path="org.eclipse.jetty.http.jar"/>
5+
<classpathentry exported="true" kind="lib" path="org.eclipse.jetty.http.jar" sourcepath="/home/thboileau/.m2/repository/org/eclipse/jetty/jetty-http/9.2.6.v20141205/jetty-http-9.2.6.v20141205-sources.jar"/>
66
<classpathentry exported="true" kind="lib" path="org.eclipse.jetty.io.jar"/>
77
<classpathentry exported="true" kind="lib" path="org.eclipse.jetty.server.jar"/>
88
<classpathentry exported="true" kind="lib" path="org.eclipse.jetty.spdy.client.jar"/>

modules/org.restlet/src/org/restlet/resource/ClientResource.java

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -610,19 +610,6 @@ public Representation delete(MediaType mediaType) throws ResourceException {
610610
return handle(Method.DELETE, mediaType);
611611
}
612612

613-
/**
614-
* By default, it throws a new resource exception.
615-
* Call {@link #doError(org.restlet.data.Status, org.restlet.Request, org.restlet.Response)}.
616-
*
617-
* @param request
618-
* The associated request.
619-
* @param response
620-
* The associated response.
621-
*/
622-
public void doError(Request request, Response response) {
623-
doError(response.getStatus(), request, response);
624-
}
625-
626613
/**
627614
* By default, it throws a new resource exception.
628615
* Call {@link #doError(org.restlet.data.Status, org.restlet.Request, org.restlet.Response)}.
@@ -632,25 +619,9 @@ public void doError(Request request, Response response) {
632619
*/
633620
@Override
634621
public void doError(Status errorStatus) {
635-
doError(errorStatus, getRequest(), getResponse());
636-
}
637-
638-
/**
639-
* By default, it throws a new resource exception.
640-
* This can be overridden to provide a different behavior.
641-
*
642-
* @param errorStatus
643-
* The error status received.
644-
* @param request
645-
* The associated request.
646-
* @param response
647-
* The associated response.
648-
*/
649-
public void doError(Status errorStatus, Request request, Response response) {
650-
throw new ResourceException(errorStatus, request, response);
622+
throw new ResourceException(errorStatus, this);
651623
}
652624

653-
654625
/**
655626
* Releases the resource by stopping any connector automatically created and
656627
* associated to the "next" property (see {@link #getNext()} method.

modules/org.restlet/src/org/restlet/resource/ResourceException.java

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,8 @@ public class ResourceException extends RuntimeException {
3737

3838
private static final long serialVersionUID = 1L;
3939

40-
/** The request associated to this exception. Could be null. */
41-
private final Request request;
42-
43-
/** The response associated to this exception. Could be null. */
44-
private final Response response;
40+
/** The resource associated to this exception. Could be null. */
41+
private final Resource resource;
4542

4643
/** The status associated to this exception. */
4744
private final Status status;
@@ -198,8 +195,8 @@ public ResourceException(Status status) {
198195
* @param status
199196
* The status to associate.
200197
*/
201-
public ResourceException(Status status, Request request, Response response) {
202-
this(status, (Throwable) ((status == null) ? null : status.getThrowable()), request, response);
198+
public ResourceException(Status status, Resource resource) {
199+
this(status, (Throwable) ((status == null) ? null : status.getThrowable()), resource);
203200
}
204201

205202
/**
@@ -237,7 +234,7 @@ public ResourceException(Status status, String description, Throwable cause) {
237234
* The wrapped cause error or exception.
238235
*/
239236
public ResourceException(Status status, Throwable cause) {
240-
this(status, cause, null, null);
237+
this(status, cause, null);
241238
}
242239

243240
/**
@@ -248,11 +245,10 @@ public ResourceException(Status status, Throwable cause) {
248245
* @param cause
249246
* The wrapped cause error or exception.
250247
*/
251-
public ResourceException(Status status, Throwable cause, Request request, Response response) {
248+
public ResourceException(Status status, Throwable cause, Resource resource) {
252249
super((status == null) ? null : status.toString(), cause);
253250
this.status = status;
254-
this.request = request;
255-
this.response = response;
251+
this.resource = resource;
256252
}
257253

258254
/**
@@ -272,7 +268,16 @@ public ResourceException(Throwable cause) {
272268
* @return The request associated to this exception.
273269
*/
274270
public Request getRequest() {
275-
return this.request;
271+
return (this.resource != null) ? this.resource.getRequest() : null;
272+
}
273+
274+
/**
275+
* Returns the resource associated to this exception.
276+
*
277+
* @return The resource associated to this exception.
278+
*/
279+
public Resource getResource() {
280+
return this.resource;
276281
}
277282

278283
/**
@@ -281,7 +286,7 @@ public Request getRequest() {
281286
* @return The response associated to this exception.
282287
*/
283288
public Response getResponse() {
284-
return this.response;
289+
return (this.resource != null) ? this.resource.getResponse() : null;
285290
}
286291

287292
/**

0 commit comments

Comments
 (0)