Changes for page ERRest In Depth

Last modified by Pascal Robert on 2012/06/10 16:01

From version 39.1
edited by Pascal Robert
on 2012/05/02 21:50
Change comment: There is no comment for this version
To version 45.1
edited by Pascal Robert
on 2012/06/10 16:01
Change comment: There is no comment for this version

Summary

Details

Page properties
Content
... ... @@ -1,3 +1,155 @@
1 +General architecture
2 +Same Origin policy
3 +Transactions
4 +HTML vs other formats
5 +Response representation
6 +Missing route
7 +Missing object
8 +POJO objects
9 +Headers
10 +Caching
11 +Adding new format
12 +Security
13 +strictMode
14 +Workflow
15 +Query arguments and RXRestFetchSpecification
16 +ERXRestNameRegistry
17 +MapClassDescription / NSDictionaryClassDescription
18 +
19 +Calling an action goes like this:
20 +
21 +{{code}}
22 +
23 +Application.dispatchRequest ->
24 +ERXRouteRequestHandler.handleRequest ->
25 +ERXRouteRequestHandler._handleRequest ->
26 +RestEntitiesController(ERXRouteController).performActionNamed(String actionName, false throwExceptions) ->
27 +RestEntitiesController(ERXRouteController).performRouteActionNamed -> RestEntitiesController(ERXRouteController).performActionWithArguments(Method, Object...) ->
28 +Method.invoke -> ...
29 +RestEntitiesController.indexAction()
30 +
31 +{{/code}}
32 +
33 +performActionNamed:
34 +
35 +{{code}}
36 +
37 +if (transactionAdaptor.transactionsEnabled() && !transactionAdaptor.isExecutingTransaction(context(), request())) {
38 + if (!transactionAdaptor.willHandleRequest(context(), request())) {
39 + if (transactionAdaptor.didHandleRequest(context(), request())) {
40 + results = stringResponse("Transaction request enqueued.");
41 + } else {
42 + results = stringResponse("Transaction executed.");
43 + }
44 + }
45 +}
46 +
47 +if (results == null) {
48 + checkAccess();
49 +}
50 +
51 +if (results == null && isAutomaticHtmlRoutingEnabled() && format() == ERXRestFormat.html()) {
52 + results = performHtmlActionNamed(actionName);
53 +}
54 +
55 +if (results == null) {
56 + results = performRouteActionNamed(actionName);
57 +}
58 +
59 +if (results == null) {
60 + results = response(null, ERXKeyFilter.filterWithAttributes());
61 +}
62 +else if (results instanceof IERXRouteComponent) {
63 + _takeRouteParametersFromRequest(results);
64 +}
65 +
66 +{{/code}}
67 +
68 +ERXRouteController.checkAccess()
69 +
70 +Will do nothing by default. Override it to check for security.
71 +
72 +{{code}}
73 +
74 +protected void checkAccess() throws SecurityException {
75 +}
76 +
77 +{{/code}}
78 +
79 +ERXRouteController.performHtmlActionNamed
80 +
81 +{{code}}
82 +
83 + protected WOActionResults performHtmlActionNamed(String actionName) throws Exception {
84 + WOActionResults results = null;
85 +
86 + String pageName = pageNameForAction(actionName);
87 + if (_NSUtilities.classWithName(pageName) != null) {
88 + try {
89 + results = pageWithName(pageName);
90 + if (!(results instanceof IERXRouteComponent)) {
91 + log.error(pageName + " does not implement IERXRouteComponent, so it will be ignored.");
92 + results = null;
93 + }
94 + }
95 + catch (WOPageNotFoundException e) {
96 + log.info(pageName + " does not exist, falling back to route controller.");
97 + results = null;
98 + }
99 + }
100 + else {
101 + log.info(pageName + " does not exist, falling back to route controller.");
102 + }
103 +
104 + if (results == null && shouldFailOnMissingHtmlPage()) {
105 + results = performUnknownAction(actionName);
106 + }
107 +
108 + return results;
109 + }
110 +
111 +{{/code}}
112 +
113 +{{code}}
114 +
115 + protected String pageNameForAction(String actionName) {
116 + return entityName() + ERXStringUtilities.capitalize(actionName) + "Page";
117 + }
118 +
119 +{{/code}}
120 +
121 +{{code}}
122 +
123 + protected boolean shouldFailOnMissingHtmlPage() {
124 + return false;
125 + }
126 +
127 +{{/code}}
128 +
129 +ERXRestUtils
130 +
131 +request > route
132 +
133 +{{code}}
134 +
135 +/**
136 + * A NameFormat that behaves like Rails -- plural entities, plural routes, lowercase underscore names
137 + * (names_like_this).
138 + */
139 + public static NameFormat RAILS = new NameFormat(true, true, NameFormat.Case.LowercaseUnderscore);
140 +
141 + /**
142 + * A NameFormat that behaves like WO -- singular entities, singular routes, camel names (NamesLikeThis).
143 + */
144 + public static NameFormat WO = new NameFormat(false, false, NameFormat.Case.CamelCase);
145 +
146 + /**
147 + * A NameFormat that behaves like WO -- singular entities, singular routes, lowercase camel names (namesLikeThis).
148 + */
149 + public static NameFormat WO_LOWER = new NameFormat(false, false, NameFormat.Case.LowerCamelCase);
150 +
151 +{{/code}}
152 +
1 1  * ERXRestContext
2 2  ** contains the editing context and an userInfo dictionnary
3 3  ** will be populated with er.rest.dateFormat, er.rest.timestampFormatter and er.rest.timestampFormat (read only for non-HTML responses)
... ... @@ -46,6 +46,7 @@
46 46  ** er.rest.timestampFormat.secondary
47 47  ** er.rest.timestampFormatter
48 48  ** er.rest.rfcDateFormat
201 +** er.rest.jodaTime
49 49  ** ERXRest.transactionsEnabled (default 'false') ERXRestTransactionRequestAdaptor
50 50  ** ERXRest.maxEventsPerTransaction (default '50') ERXRestTransactionRequestAdaptor
51 51  ** ERXRest.accessControlAllowRequestHeaders (ERXRouteController)
... ... @@ -56,7 +56,7 @@
56 56  ** ERXRest.accessControlMaxAge (ERXRouteController)
57 57  *** (default 1728000) This header indicates how long the results of a preflight request can be cached. For an example of a preflight request, see the above examples.
58 58  ** ERXRest.accessControlAllowOrigin (ERXRouteController)
59 -*** Set the value to '**' to enable all origins. See https:~/~/developer.mozilla.org/En/HTTP_access_control#Access-Control-Allow-Origin**
212 +*** Set the value to '**' to enable all origins. See [[https://developer.mozilla.org/En/HTTP_access_control#Access-Control-Allow-Origin]]**
60 60  * JSON Schema
61 61  ** {{code}}
62 62  /something?schema=true
... ... @@ -70,31 +70,6 @@
70 70  }
71 71  {{/code}}
72 72  
73 -Same Origin policy
74 -Transactions
75 -HTML vs other formats
76 -Response representation
77 -Missing route
78 -Missing object
79 -POJO objects
80 -Headers
81 -Caching
82 -Adding new format
83 -Security
84 -strictMode
85 -Workflow
86 -Query arguments and RXRestFetchSpecification
87 -ERXRestNameRegistry
88 -MapClassDescription / NSDictionaryClassDescription
89 -
90 -ERXRestUtils
91 -Properties
92 -er.rest.dateFormat
93 -er.rest.timestampFormat
94 -er.rest.rfcDateFormat
95 -
96 -request > route
97 -
98 98  Application(ERXApplication).dispatchRequest(WORequest) line: 2051
99 99  ERXRouteRequestHandler(WOActionRequestHandler).//handleRequest(WORequest) line: 221
100 100  ERXRouteRequestHandler.getRequestHandlerPathForRequest(WORequest) line: 782//
... ... @@ -126,13 +126,3 @@
126 126  | ERXRest.strictMode | ERXRest.strictMode
127 127  \\          |
128 128  ERXRouteController
129 -
130 -Properties
131 -
132 -ERXRest.accessControlAllowRequestHeaders
133 -ERXRest.accessControlAllowRequestMethods
134 -ERXRest.defaultFormat
135 -ERXRest.strictMode
136 -ERXRest.allowWindowNameCrossDomainTransport
137 -ERXRest.accessControlMaxAge
138 -ERXRest.accessControlAllowOrigin