Mercurial > hg > AnnotationManagerN4J
comparison src/main/java/de/mpiwg/itgroup/annotations/restlet/utils/UrlPrefixFilter.java @ 96:8fefa4651d00
changed source indentation.
author | casties |
---|---|
date | Tue, 10 Feb 2015 19:00:13 +0100 |
parents | fcb6fe10e08c |
children |
comparison
equal
deleted
inserted
replaced
95:acd44dfec9c8 | 96:8fefa4651d00 |
---|---|
33 * @author casties | 33 * @author casties |
34 * | 34 * |
35 */ | 35 */ |
36 public class UrlPrefixFilter extends Filter { | 36 public class UrlPrefixFilter extends Filter { |
37 | 37 |
38 private String prefix = null; | 38 private String prefix = null; |
39 | 39 |
40 /** | 40 /** |
41 * Set the prefix to add. | 41 * Set the prefix to add. |
42 * | 42 * |
43 * @param prefix | 43 * @param prefix |
44 */ | 44 */ |
45 public void setPrefix(String prefix) { | 45 public void setPrefix(String prefix) { |
46 if (!prefix.startsWith("/")) { | 46 if (!prefix.startsWith("/")) { |
47 prefix = "/" + prefix; | 47 prefix = "/" + prefix; |
48 } | 48 } |
49 this.prefix = prefix; | 49 this.prefix = prefix; |
50 } | 50 } |
51 | 51 |
52 @Override | 52 @Override |
53 protected int beforeHandle(Request request, Response response) { | 53 protected int beforeHandle(Request request, Response response) { |
54 // get ref to change | 54 // get ref to change |
55 Reference ref = request.getResourceRef(); | 55 Reference ref = request.getResourceRef(); |
56 String path = ref.getPath(); | 56 String path = ref.getPath(); |
57 // add prefix to path | 57 // add prefix to path |
58 ref.setPath(prefix + path); | 58 ref.setPath(prefix + path); |
59 // change baseRef as well | 59 // change baseRef as well |
60 Reference baseRef = ref.getBaseRef(); | 60 Reference baseRef = ref.getBaseRef(); |
61 String basePath = baseRef.getPath(); | 61 String basePath = baseRef.getPath(); |
62 // add prefix to base ref path | 62 // add prefix to base ref path |
63 baseRef.setPath(prefix + basePath); | 63 baseRef.setPath(prefix + basePath); |
64 return super.beforeHandle(request, response); | 64 return super.beforeHandle(request, response); |
65 } | 65 } |
66 | 66 |
67 } | 67 } |