~hsiung0911/sahana-eden/test

« back to all changes in this revision

Viewing changes to static/scripts/gis/openlayers/lib/OpenLayers/Protocol/HTTP.js

  • Committer: eliao
  • Date: 2010-08-01 09:56:45 UTC
  • Revision ID: eliao@ibm-l3bw307-20100801095645-gsq9wcmjan0o0tby
This is my change

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Copyright (c) 2006-2008 MetaCarta, Inc., published under the Clear BSD
 
2
 * license.  See http://svn.openlayers.org/trunk/openlayers/license.txt for the
 
3
 * full text of the license. */
 
4
 
 
5
/**
 
6
 * @requires OpenLayers/Protocol.js
 
7
 * @requires OpenLayers/Feature/Vector.js
 
8
 * @requires OpenLayers/Filter/Spatial.js
 
9
 * @requires OpenLayers/Filter/Comparison.js
 
10
 * @requires OpenLayers/Filter/Logical.js
 
11
 */
 
12
 
 
13
/**
 
14
 * Class: OpenLayers.Protocol.HTTP
 
15
 * A basic HTTP protocol for vector layers.  Create a new instance with the
 
16
 *     <OpenLayers.Protocol.HTTP> constructor.
 
17
 *
 
18
 * Inherits from:
 
19
 *  - <OpenLayers.Protocol>
 
20
 */
 
21
OpenLayers.Protocol.HTTP = OpenLayers.Class(OpenLayers.Protocol, {
 
22
 
 
23
    /**
 
24
     * Property: url
 
25
     * {String} Service URL, read-only, set through the options
 
26
     *     passed to constructor.
 
27
     */
 
28
    url: null,
 
29
 
 
30
    /**
 
31
     * Property: headers
 
32
     * {Object} HTTP request headers, read-only, set through the options
 
33
     *     passed to the constructor,
 
34
     *     Example: {'Content-Type': 'plain/text'}
 
35
     */
 
36
    headers: null,
 
37
 
 
38
    /**
 
39
     * Property: params
 
40
     * {Object} Parameters of GET requests, read-only, set through the options
 
41
     *     passed to the constructor,
 
42
     *     Example: {'bbox': '5,5,5,5'}
 
43
     */
 
44
    params: null,
 
45
    
 
46
    /**
 
47
     * Property: callback
 
48
     * {Object} Function to be called when the <read>, <create>,
 
49
     *     <update>, <delete> or <commit> operation completes, read-only,
 
50
     *     set through the options passed to the constructor.
 
51
     */
 
52
    callback: null,
 
53
 
 
54
    /**
 
55
     * Property: scope
 
56
     * {Object} Callback execution scope, read-only, set through the
 
57
     *     options passed to the constructor.
 
58
     */
 
59
    scope: null,
 
60
 
 
61
    /**
 
62
     * Property: readWithPOST
 
63
     * {Boolean} true if read operations are done with POST requests
 
64
     *     instead of GET, defaults to false.
 
65
     */
 
66
    readWithPOST: false,
 
67
 
 
68
    /**
 
69
     * Property: wildcarded.
 
70
     * {Boolean} If true percent signs are added around values
 
71
     *     read from LIKE filters, for example if the protocol
 
72
     *     read method is passed a LIKE filter whose property
 
73
     *     is "foo" and whose value is "bar" the string
 
74
     *     "foo__ilike=%bar%" will be sent in the query string;
 
75
     *     defaults to false.
 
76
     */
 
77
    wildcarded: false,
 
78
 
 
79
    /**
 
80
     * Constructor: OpenLayers.Protocol.HTTP
 
81
     * A class for giving layers generic HTTP protocol.
 
82
     *
 
83
     * Parameters:
 
84
     * options - {Object} Optional object whose properties will be set on the
 
85
     *     instance.
 
86
     *
 
87
     * Valid options include:
 
88
     * url - {String}
 
89
     * headers - {Object} 
 
90
     * params - {Object}
 
91
     * format - {<OpenLayers.Format>}
 
92
     * callback - {Function}
 
93
     * scope - {Object}
 
94
     */
 
95
    initialize: function(options) {
 
96
        options = options || {};
 
97
        this.params = {};
 
98
        this.headers = {};
 
99
        OpenLayers.Protocol.prototype.initialize.apply(this, arguments);
 
100
    },
 
101
    
 
102
    /**
 
103
     * APIMethod: destroy
 
104
     * Clean up the protocol.
 
105
     */
 
106
    destroy: function() {
 
107
        this.params = null;
 
108
        this.headers = null;
 
109
        OpenLayers.Protocol.prototype.destroy.apply(this);
 
110
    },
 
111
   
 
112
    /**
 
113
     * APIMethod: read
 
114
     * Construct a request for reading new features.
 
115
     *
 
116
     * Parameters:
 
117
     * options - {Object} Optional object for configuring the request.
 
118
     *     This object is modified and should not be reused.
 
119
     *
 
120
     * Valid options:
 
121
     * url - {String} Url for the request.
 
122
     * params - {Object} Parameters to get serialized as a query string.
 
123
     * headers - {Object} Headers to be set on the request.
 
124
     * filter - {<OpenLayers.Filter>} Filter to get serialized as a
 
125
     *     query string.
 
126
     * readWithPOST - {Boolean} If the request should be done with POST.
 
127
     *
 
128
     * Returns:
 
129
     * {<OpenLayers.Protocol.Response>} A response object, whose "priv" property
 
130
     *     references the HTTP request, this object is also passed to the
 
131
     *     callback function when the request completes, its "features" property
 
132
     *     is then populated with the the features received from the server.
 
133
     */
 
134
    read: function(options) {
 
135
        OpenLayers.Protocol.prototype.read.apply(this, arguments);
 
136
        options = OpenLayers.Util.applyDefaults(options, this.options);
 
137
        options.params = OpenLayers.Util.applyDefaults(
 
138
            options.params, this.options.params);
 
139
        if(options.filter) {
 
140
            options.params = this.filterToParams(
 
141
                options.filter, options.params);
 
142
        }
 
143
        var readWithPOST = (options.readWithPOST !== undefined) ?
 
144
                           options.readWithPOST : this.readWithPOST;
 
145
        var resp = new OpenLayers.Protocol.Response({requestType: "read"});
 
146
        if(readWithPOST) {
 
147
            resp.priv = OpenLayers.Request.POST({
 
148
                url: options.url,
 
149
                callback: this.createCallback(this.handleRead, resp, options),
 
150
                data: OpenLayers.Util.getParameterString(options.params),
 
151
                headers: {
 
152
                    "Content-Type": "application/x-www-form-urlencoded"
 
153
                }
 
154
            });
 
155
        } else {
 
156
            resp.priv = OpenLayers.Request.GET({
 
157
                url: options.url,
 
158
                callback: this.createCallback(this.handleRead, resp, options),
 
159
                params: options.params,
 
160
                headers: options.headers
 
161
            });
 
162
        }
 
163
        return resp;
 
164
    },
 
165
 
 
166
    /**
 
167
     * Method: handleRead
 
168
     * Individual callbacks are created for read, create and update, should
 
169
     *     a subclass need to override each one separately.
 
170
     *
 
171
     * Parameters:
 
172
     * resp - {<OpenLayers.Protocol.Response>} The response object to pass to
 
173
     *     the user callback.
 
174
     * options - {Object} The user options passed to the read call.
 
175
     */
 
176
    handleRead: function(resp, options) {
 
177
        this.handleResponse(resp, options);
 
178
    },
 
179
 
 
180
    /**
 
181
     * Method: filterToParams
 
182
     * Convert an <OpenLayers.Filter> object to parameters.
 
183
     *
 
184
     * Parameters:
 
185
     * filter - {OpenLayers.Filter} filter to convert.
 
186
     * params - {Object} The parameters object.
 
187
     *
 
188
     * Returns:
 
189
     * {Object} The resulting parameters object.
 
190
     */
 
191
    filterToParams: function(filter, params) {
 
192
        params = params || {};
 
193
        var className = filter.CLASS_NAME;
 
194
        var filterType = className.substring(className.lastIndexOf(".") + 1);
 
195
        switch(filterType) {
 
196
            case "Spatial":
 
197
                switch(filter.type) {
 
198
                    case OpenLayers.Filter.Spatial.BBOX:
 
199
                        params.bbox = filter.value.toArray();
 
200
                        break;
 
201
                    case OpenLayers.Filter.Spatial.DWITHIN:
 
202
                        params.tolerance = filter.distance;
 
203
                        // no break here
 
204
                    case OpenLayers.Filter.Spatial.WITHIN:
 
205
                        params.lon = filter.value.x;
 
206
                        params.lat = filter.value.y;
 
207
                        break;
 
208
                    default:
 
209
                        OpenLayers.Console.warn(
 
210
                            "Unknown spatial filter type " + filter.type);
 
211
                }
 
212
                break;
 
213
            case "Comparison":
 
214
                var op = OpenLayers.Protocol.HTTP.COMP_TYPE_TO_OP_STR[filter.type];
 
215
                if(op !== undefined) {
 
216
                    var value = filter.value;
 
217
                    if(filter.type == OpenLayers.Filter.Comparison.LIKE) {
 
218
                        value = this.regex2value(value);
 
219
                        if(this.wildcarded) {
 
220
                            value = "%" + value + "%";
 
221
                        }
 
222
                    }
 
223
                    params[filter.property + "__" + op] = value;
 
224
                    params.queryable = params.queryable || [];
 
225
                    params.queryable.push(filter.property);
 
226
                } else {
 
227
                    OpenLayers.Console.warn(
 
228
                        "Unknown comparison filter type " + filter.type);
 
229
                }
 
230
                break;
 
231
            case "Logical":
 
232
                if(filter.type === OpenLayers.Filter.Logical.AND) {
 
233
                    for(var i=0,len=filter.filters.length; i<len; i++) {
 
234
                        params = this.filterToParams(filter.filters[i], params);
 
235
                    }
 
236
                } else {
 
237
                    OpenLayers.Console.warn(
 
238
                        "Unsupported logical filter type " + filter.type);
 
239
                }
 
240
                break;
 
241
            default:
 
242
                OpenLayers.Console.warn("Unknown filter type " + filterType);
 
243
        }
 
244
        return params;
 
245
    },
 
246
 
 
247
    /**
 
248
     * Method: regex2value
 
249
     * Convert the value from a regular expression string to a LIKE/ILIKE
 
250
     * string known to the web service.
 
251
     *
 
252
     * Parameters:
 
253
     * value - {String} The regex string.
 
254
     *
 
255
     * Returns:
 
256
     * {String} The converted string.
 
257
     */
 
258
    regex2value: function(value) {
 
259
 
 
260
        // highly sensitive!! Do not change this without running the
 
261
        // Protocol/HTTP.html unit tests
 
262
 
 
263
        // convert % to \%
 
264
        value = value.replace(/%/g, "\\%");
 
265
 
 
266
        // convert \\. to \\_ (\\.* occurences converted later)
 
267
        value = value.replace(/\\\\\.(\*)?/g, function($0, $1) {
 
268
            return $1 ? $0 : "\\\\_";
 
269
        });
 
270
 
 
271
        // convert \\.* to \\%
 
272
        value = value.replace(/\\\\\.\*/g, "\\\\%");
 
273
 
 
274
        // convert . to _ (\. and .* occurences converted later)
 
275
        value = value.replace(/(\\)?\.(\*)?/g, function($0, $1, $2) {
 
276
            return $1 || $2 ? $0 : "_";
 
277
        });
 
278
 
 
279
        // convert .* to % (\.* occurnces converted later)
 
280
        value = value.replace(/(\\)?\.\*/g, function($0, $1) {
 
281
            return $1 ? $0 : "%";
 
282
        });
 
283
 
 
284
        // convert \. to .
 
285
        value = value.replace(/\\\./g, ".");
 
286
 
 
287
        // replace \* with * (watching out for \\*)
 
288
        value = value.replace(/(\\)?\\\*/g, function($0, $1) {
 
289
            return $1 ? $0 : "*";
 
290
        });
 
291
 
 
292
        return value;
 
293
    },
 
294
 
 
295
    /**
 
296
     * APIMethod: create
 
297
     * Construct a request for writing newly created features.
 
298
     *
 
299
     * Parameters:
 
300
     * features - {Array({<OpenLayers.Feature.Vector>})} or
 
301
     *     {<OpenLayers.Feature.Vector>}
 
302
     * options - {Object} Optional object for configuring the request.
 
303
     *     This object is modified and should not be reused.
 
304
     *
 
305
     * Returns:
 
306
     * {<OpenLayers.Protocol.Response>} An <OpenLayers.Protocol.Response>
 
307
     *     object, whose "priv" property references the HTTP request, this 
 
308
     *     object is also passed to the callback function when the request
 
309
     *     completes, its "features" property is then populated with the
 
310
     *     the features received from the server.
 
311
     */
 
312
    create: function(features, options) {
 
313
        options = OpenLayers.Util.applyDefaults(options, this.options);
 
314
 
 
315
        var resp = new OpenLayers.Protocol.Response({
 
316
            reqFeatures: features,
 
317
            requestType: "create"
 
318
        });
 
319
 
 
320
        resp.priv = OpenLayers.Request.POST({
 
321
            url: options.url,
 
322
            callback: this.createCallback(this.handleCreate, resp, options),
 
323
            headers: options.headers,
 
324
            data: this.format.write(features)
 
325
        });
 
326
 
 
327
        return resp;
 
328
    },
 
329
 
 
330
    /**
 
331
     * Method: handleCreate
 
332
     * Called the the request issued by <create> is complete.  May be overridden
 
333
     *     by subclasses.
 
334
     *
 
335
     * Parameters:
 
336
     * resp - {<OpenLayers.Protocol.Response>} The response object to pass to
 
337
     *     any user callback.
 
338
     * options - {Object} The user options passed to the create call.
 
339
     */
 
340
    handleCreate: function(resp, options) {
 
341
        this.handleResponse(resp, options);
 
342
    },
 
343
 
 
344
    /**
 
345
     * APIMethod: update
 
346
     * Construct a request updating modified feature.
 
347
     *
 
348
     * Parameters:
 
349
     * feature - {<OpenLayers.Feature.Vector>}
 
350
     * options - {Object} Optional object for configuring the request.
 
351
     *     This object is modified and should not be reused.
 
352
     *
 
353
     * Returns:
 
354
     * {<OpenLayers.Protocol.Response>} An <OpenLayers.Protocol.Response>
 
355
     *     object, whose "priv" property references the HTTP request, this 
 
356
     *     object is also passed to the callback function when the request
 
357
     *     completes, its "features" property is then populated with the
 
358
     *     the feature received from the server.
 
359
     */
 
360
    update: function(feature, options) {
 
361
        options = options || {};
 
362
        var url = options.url ||
 
363
                  feature.url ||
 
364
                  this.options.url + "/" + feature.fid;
 
365
        options = OpenLayers.Util.applyDefaults(options, this.options);
 
366
 
 
367
        var resp = new OpenLayers.Protocol.Response({
 
368
            reqFeatures: feature,
 
369
            requestType: "update"
 
370
        });
 
371
 
 
372
        resp.priv = OpenLayers.Request.PUT({
 
373
            url: url,
 
374
            callback: this.createCallback(this.handleUpdate, resp, options),
 
375
            headers: options.headers,
 
376
            data: this.format.write(feature)
 
377
        });
 
378
 
 
379
        return resp;
 
380
    },
 
381
 
 
382
    /**
 
383
     * Method: handleUpdate
 
384
     * Called the the request issued by <update> is complete.  May be overridden
 
385
     *     by subclasses.
 
386
     *
 
387
     * Parameters:
 
388
     * resp - {<OpenLayers.Protocol.Response>} The response object to pass to
 
389
     *     any user callback.
 
390
     * options - {Object} The user options passed to the update call.
 
391
     */
 
392
    handleUpdate: function(resp, options) {
 
393
        this.handleResponse(resp, options);
 
394
    },
 
395
 
 
396
    /**
 
397
     * APIMethod: delete
 
398
     * Construct a request deleting a removed feature.
 
399
     *
 
400
     * Parameters:
 
401
     * feature - {<OpenLayers.Feature.Vector>}
 
402
     * options - {Object} Optional object for configuring the request.
 
403
     *     This object is modified and should not be reused.
 
404
     *
 
405
     * Returns:
 
406
     * {<OpenLayers.Protocol.Response>} An <OpenLayers.Protocol.Response>
 
407
     *     object, whose "priv" property references the HTTP request, this 
 
408
     *     object is also passed to the callback function when the request
 
409
     *     completes.
 
410
     */
 
411
    "delete": function(feature, options) {
 
412
        options = options || {};
 
413
        var url = options.url ||
 
414
                  feature.url ||
 
415
                  this.options.url + "/" + feature.fid;
 
416
        options = OpenLayers.Util.applyDefaults(options, this.options);
 
417
 
 
418
        var resp = new OpenLayers.Protocol.Response({
 
419
            reqFeatures: feature,
 
420
            requestType: "delete"
 
421
        });
 
422
 
 
423
        resp.priv = OpenLayers.Request.DELETE({
 
424
            url: url,
 
425
            callback: this.createCallback(this.handleDelete, resp, options),
 
426
            headers: options.headers
 
427
        });
 
428
 
 
429
        return resp;
 
430
    },
 
431
 
 
432
    /**
 
433
     * Method: handleDelete
 
434
     * Called the the request issued by <delete> is complete.  May be overridden
 
435
     *     by subclasses.
 
436
     *
 
437
     * Parameters:
 
438
     * resp - {<OpenLayers.Protocol.Response>} The response object to pass to
 
439
     *     any user callback.
 
440
     * options - {Object} The user options passed to the delete call.
 
441
     */
 
442
    handleDelete: function(resp, options) {
 
443
        this.handleResponse(resp, options);
 
444
    },
 
445
 
 
446
    /**
 
447
     * Method: handleResponse
 
448
     * Called by CRUD specific handlers.
 
449
     *
 
450
     * Parameters:
 
451
     * resp - {<OpenLayers.Protocol.Response>} The response object to pass to
 
452
     *     any user callback.
 
453
     * options - {Object} The user options passed to the create, read, update,
 
454
     *     or delete call.
 
455
     */
 
456
    handleResponse: function(resp, options) {
 
457
        var request = resp.priv;
 
458
        if(options.callback) {
 
459
            if(request.status >= 200 && request.status < 300) {
 
460
                // success
 
461
                if(resp.requestType != "delete") {
 
462
                    resp.features = this.parseFeatures(request);
 
463
                }
 
464
                resp.code = OpenLayers.Protocol.Response.SUCCESS;
 
465
            } else {
 
466
                // failure
 
467
                resp.code = OpenLayers.Protocol.Response.FAILURE;
 
468
            }
 
469
            options.callback.call(options.scope, resp);
 
470
        }
 
471
    },
 
472
 
 
473
    /**
 
474
     * Method: parseFeatures
 
475
     * Read HTTP response body and return features.
 
476
     *
 
477
     * Parameters:
 
478
     * request - {XMLHttpRequest} The request object
 
479
     *
 
480
     * Returns:
 
481
     * {Array({<OpenLayers.Feature.Vector>})} or
 
482
     *     {<OpenLayers.Feature.Vector>} Array of features or a single feature.
 
483
     */
 
484
    parseFeatures: function(request) {
 
485
        var doc = request.responseXML;
 
486
        if (!doc || !doc.documentElement) {
 
487
            doc = request.responseText;
 
488
        }
 
489
        if (!doc || doc.length <= 0) {
 
490
            return null;
 
491
        }
 
492
        return this.format.read(doc);
 
493
    },
 
494
 
 
495
    /**
 
496
     * APIMethod: commit
 
497
     * Iterate over each feature and take action based on the feature state.
 
498
     *     Possible actions are create, update and delete.
 
499
     *
 
500
     * Parameters:
 
501
     * features - {Array({<OpenLayers.Feature.Vector>})}
 
502
     * options - {Object} Optional object for setting up intermediate commit
 
503
     *     callbacks.
 
504
     *
 
505
     * Valid options:
 
506
     * create - {Object} Optional object to be passed to the <create> method.
 
507
     * update - {Object} Optional object to be passed to the <update> method.
 
508
     * delete - {Object} Optional object to be passed to the <delete> method.
 
509
     * callback - {Function} Optional function to be called when the commit
 
510
     *     is complete.
 
511
     * scope - {Object} Optional object to be set as the scope of the callback.
 
512
     *
 
513
     * Returns:
 
514
     * {Array(<OpenLayers.Protocol.Response>)} An array of response objects,
 
515
     *     one per request made to the server, each object's "priv" property
 
516
     *     references the corresponding HTTP request.
 
517
     */
 
518
    commit: function(features, options) {
 
519
        options = OpenLayers.Util.applyDefaults(options, this.options);
 
520
        var resp = [], nResponses = 0;
 
521
        
 
522
        // Divide up features before issuing any requests.  This properly
 
523
        // counts requests in the event that any responses come in before
 
524
        // all requests have been issued.
 
525
        var types = {};
 
526
        types[OpenLayers.State.INSERT] = [];
 
527
        types[OpenLayers.State.UPDATE] = [];
 
528
        types[OpenLayers.State.DELETE] = [];
 
529
        var feature, list, requestFeatures = [];
 
530
        for(var i=0, len=features.length; i<len; ++i) {
 
531
            feature = features[i];
 
532
            list = types[feature.state];
 
533
            if(list) {
 
534
                list.push(feature);
 
535
                requestFeatures.push(feature); 
 
536
            }
 
537
        }
 
538
        // tally up number of requests
 
539
        var nRequests = (types[OpenLayers.State.INSERT].length > 0 ? 1 : 0) +
 
540
            types[OpenLayers.State.UPDATE].length +
 
541
            types[OpenLayers.State.DELETE].length;
 
542
        
 
543
        // This response will be sent to the final callback after all the others
 
544
        // have been fired.
 
545
        var success = true;
 
546
        var finalResponse = new OpenLayers.Protocol.Response({
 
547
            reqFeatures: requestFeatures        
 
548
        });
 
549
        
 
550
        function insertCallback(response) {
 
551
            var len = response.features ? response.features.length : 0;
 
552
            var fids = new Array(len);
 
553
            for(var i=0; i<len; ++i) {
 
554
                fids[i] = response.features[i].fid;
 
555
            }   
 
556
            finalResponse.insertIds = fids;
 
557
            callback.apply(this, [response]);
 
558
        }
 
559
 
 
560
        function callback(response) {
 
561
            this.callUserCallback(response, options);
 
562
            success = success && response.success();
 
563
            nResponses++;
 
564
            if (nResponses >= nRequests) {
 
565
                if (options.callback) {
 
566
                    finalResponse.code = success ? 
 
567
                        OpenLayers.Protocol.Response.SUCCESS :
 
568
                        OpenLayers.Protocol.Response.FAILURE;
 
569
                    options.callback.apply(options.scope, [finalResponse]);
 
570
                }    
 
571
            }
 
572
        }
 
573
 
 
574
        // start issuing requests
 
575
        var queue = types[OpenLayers.State.INSERT];
 
576
        if(queue.length > 0) {
 
577
            resp.push(this.create(
 
578
                queue, OpenLayers.Util.applyDefaults(
 
579
                    {callback: insertCallback, scope: this}, options.create
 
580
                )
 
581
            ));
 
582
        }
 
583
        queue = types[OpenLayers.State.UPDATE];
 
584
        for(var i=queue.length-1; i>=0; --i) {
 
585
            resp.push(this.update(
 
586
                queue[i], OpenLayers.Util.applyDefaults(
 
587
                    {callback: callback, scope: this}, options.update
 
588
                ))
 
589
            );
 
590
        }
 
591
        queue = types[OpenLayers.State.DELETE];
 
592
        for(var i=queue.length-1; i>=0; --i) {
 
593
            resp.push(this["delete"](
 
594
                queue[i], OpenLayers.Util.applyDefaults(
 
595
                    {callback: callback, scope: this}, options["delete"]
 
596
                ))
 
597
            );
 
598
        }
 
599
        return resp;
 
600
    },
 
601
 
 
602
    /**
 
603
     * APIMethod: abort
 
604
     * Abort an ongoing request, the response object passed to
 
605
     * this method must come from this HTTP protocol (as a result
 
606
     * of a create, read, update, delete or commit operation).
 
607
     *
 
608
     * Parameters:
 
609
     * response - {<OpenLayers.Protocol.Response>}
 
610
     */
 
611
    abort: function(response) {
 
612
        if (response) {
 
613
            response.priv.abort();
 
614
        }
 
615
    },
 
616
 
 
617
    /**
 
618
     * Method: callUserCallback
 
619
     * This method is used from within the commit method each time an
 
620
     *     an HTTP response is received from the server, it is responsible
 
621
     *     for calling the user-supplied callbacks.
 
622
     *
 
623
     * Parameters:
 
624
     * resp - {<OpenLayers.Protocol.Response>}
 
625
     * options - {Object} The map of options passed to the commit call.
 
626
     */
 
627
    callUserCallback: function(resp, options) {
 
628
        var opt = options[resp.requestType];
 
629
        if(opt && opt.callback) {
 
630
            opt.callback.call(opt.scope, resp);
 
631
        }
 
632
    },
 
633
 
 
634
    CLASS_NAME: "OpenLayers.Protocol.HTTP" 
 
635
});
 
636
 
 
637
/**
 
638
 * Property: OpenLayers.Protocol.HTTP.COMP_TYPE_TO_OP_STR
 
639
 * {Object} A private class-level property mapping the
 
640
 *     OpenLayers.Filter.Comparison types to the operation
 
641
 *     strings of the protocol.
 
642
 */
 
643
(function() {
 
644
    var o = OpenLayers.Protocol.HTTP.COMP_TYPE_TO_OP_STR = {};
 
645
    o[OpenLayers.Filter.Comparison.EQUAL_TO]                 = "eq";
 
646
    o[OpenLayers.Filter.Comparison.NOT_EQUAL_TO]             = "ne";
 
647
    o[OpenLayers.Filter.Comparison.LESS_THAN]                = "lt";
 
648
    o[OpenLayers.Filter.Comparison.LESS_THAN_OR_EQUAL_TO]    = "lte";
 
649
    o[OpenLayers.Filter.Comparison.GREATER_THAN]             = "gt";
 
650
    o[OpenLayers.Filter.Comparison.GREATER_THAN_OR_EQUAL_TO] = "gte";
 
651
    o[OpenLayers.Filter.Comparison.LIKE]                     = "ilike";
 
652
})();
 
653