Wiki source code of Session.java Addition

Version 3.1 by David Avendasora on 2008/03/06 09:48

Show last authors
1 These additions are based on a more advanced Stateless RMI concept by Florijan Stamenkovic.
2
3 {{code}}
4
5 public EOFetchSpecification clientSideRequestGetFetchSpecification(String fetchSpecification, String entity) {
6 return getFetchSpecification(fetchSpecification, entity);
7 }
8
9 public EOFetchSpecification getFetchSpecification(String fetchSpecification, String entity){
10 try{
11 return EOFetchSpecification.fetchSpecificationNamed(fetchSpecification, entity);
12 }catch(Exception ex){
13 NSLog.out.appendln(ex);
14 return null;
15 }
16 }
17
18 {{/code}}
19
20 {{color value="red"}}
21 CAUTION:
22 {{/color}}
23
24 Due to security concerns you cannot call FetchSpecifications from the client-side that use a Raw SQL Expression without implementing the delegate method [[distributionContextShouldFetchObjectsWithFetchSpecification>>http://developer.apple.com/documentation/MacOSXServer/Reference/WO54_Reference/com/webobjects/eodistribution/EODistributionContext.Delegate.html]] which this code does NOT do.
25
26 If you try to, you will get the following exception in the server log:
27
28 {{color value="red"}}
29 Server exception: The fetchSpecification YourFetchSpecificationWithRawSQLExpression was not allowed to execute on the server. If your application needs to execute this method, the security needs to be relaxed by implementing the delegate method distributionContextShouldFetchObjectsWithFetchSpecification
30 {{/color}}
31
32 and this code will return null to the client instead of the expected FetchSpecification.