author | Giulio Cesare Solaroli <giulio.cesare@solaroli.it> | 2011-10-03 16:04:12 (UTC) |
---|---|---|
committer | Giulio Cesare Solaroli <giulio.cesare@solaroli.it> | 2011-10-03 16:04:12 (UTC) |
commit | 541bb378ddece2eab135a8066a16994e94436dea (patch) (unidiff) | |
tree | ff160ea3e26f7fe07fcfd401387c5a0232ca715e /frontend/beta/js/Clipperz/PM/DataModel/RecordVersion.js | |
parent | 1bf431fd3d45cbdf4afa3e12afefe5d24f4d3bc7 (diff) | |
parent | ecad5e895831337216544e81f1a467e0c68c4a6a (diff) | |
download | clipperz-541bb378ddece2eab135a8066a16994e94436dea.zip clipperz-541bb378ddece2eab135a8066a16994e94436dea.tar.gz clipperz-541bb378ddece2eab135a8066a16994e94436dea.tar.bz2 |
Merge pull request #1 from gcsolaroli/master
First version of the restructured repository
Diffstat (limited to 'frontend/beta/js/Clipperz/PM/DataModel/RecordVersion.js') (more/less context) (ignore whitespace changes)
-rw-r--r-- | frontend/beta/js/Clipperz/PM/DataModel/RecordVersion.js | 535 |
1 files changed, 535 insertions, 0 deletions
diff --git a/frontend/beta/js/Clipperz/PM/DataModel/RecordVersion.js b/frontend/beta/js/Clipperz/PM/DataModel/RecordVersion.js new file mode 100644 index 0000000..d2b3e12 --- a/dev/null +++ b/frontend/beta/js/Clipperz/PM/DataModel/RecordVersion.js | |||
@@ -0,0 +1,535 @@ | |||
1 | /* | ||
2 | |||
3 | Copyright 2008-2011 Clipperz Srl | ||
4 | |||
5 | This file is part of Clipperz's Javascript Crypto Library. | ||
6 | Javascript Crypto Library provides web developers with an extensive | ||
7 | and efficient set of cryptographic functions. The library aims to | ||
8 | obtain maximum execution speed while preserving modularity and | ||
9 | reusability. | ||
10 | For further information about its features and functionalities please | ||
11 | refer to http://www.clipperz.com | ||
12 | |||
13 | * Javascript Crypto Library is free software: you can redistribute | ||
14 | it and/or modify it under the terms of the GNU Affero General Public | ||
15 | License as published by the Free Software Foundation, either version | ||
16 | 3 of the License, or (at your option) any later version. | ||
17 | |||
18 | * Javascript Crypto Library is distributed in the hope that it will | ||
19 | be useful, but WITHOUT ANY WARRANTY; without even the implied | ||
20 | warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
21 | See the GNU Affero General Public License for more details. | ||
22 | |||
23 | * You should have received a copy of the GNU Affero General Public | ||
24 | License along with Javascript Crypto Library. If not, see | ||
25 | <http://www.gnu.org/licenses/>. | ||
26 | |||
27 | */ | ||
28 | |||
29 | if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } | ||
30 | if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } | ||
31 | if (typeof(Clipperz.PM.DataModel) == 'undefined') { Clipperz.PM.DataModel = {}; } | ||
32 | |||
33 | |||
34 | //############################################################################# | ||
35 | |||
36 | Clipperz.PM.DataModel.RecordVersion = function(aRecord, args) { | ||
37 | args = args || {}; | ||
38 | |||
39 | this._record = aRecord; | ||
40 | |||
41 | this._reference = args.reference || Clipperz.PM.Crypto.randomKey(); | ||
42 | this._version = args.version || Clipperz.PM.Crypto.encryptingFunctions.currentVersion; | ||
43 | this._key = args.key || Clipperz.PM.Crypto.randomKey();; | ||
44 | |||
45 | this._previousVersion = args.previousVersion || null; | ||
46 | this._previousVersionKey = args.previousVersionKey || null; | ||
47 | |||
48 | this.setIsBrandNew(args.reference == null); | ||
49 | |||
50 | if (this.isBrandNew()) { | ||
51 | this._fields = {}; | ||
52 | |||
53 | this.setShouldLoadData(false); | ||
54 | this.setShouldDecryptData(false); | ||
55 | this.setShouldProcessData(false); | ||
56 | } else { | ||
57 | if (typeof(args.fields) != 'undefined') { | ||
58 | this.processFieldData(args.fields); | ||
59 | |||
60 | this.setShouldLoadData(false); | ||
61 | this.setShouldDecryptData(false); | ||
62 | this.setShouldProcessData(false); | ||
63 | } else { | ||
64 | if (typeof(args.data) != 'undefined') { | ||
65 | this.setShouldLoadData(false); | ||
66 | } else { | ||
67 | this.setShouldLoadData(true); | ||
68 | } | ||
69 | this.setShouldDecryptData(true); | ||
70 | this.setShouldProcessData(true); | ||
71 | } | ||
72 | } | ||
73 | |||
74 | this._serverData = args.data; | ||
75 | this._decryptedData = null; | ||
76 | |||
77 | return this; | ||
78 | } | ||
79 | |||
80 | Clipperz.PM.DataModel.RecordVersion.prototype = MochiKit.Base.update(null, { | ||
81 | |||
82 | 'toString': function() { | ||
83 | return "RecordVersion"; | ||
84 | }, | ||
85 | |||
86 | //------------------------------------------------------------------------- | ||
87 | |||
88 | 'record': function() { | ||
89 | return this._record; | ||
90 | }, | ||
91 | |||
92 | //------------------------------------------------------------------------- | ||
93 | |||
94 | 'reference': function() { | ||
95 | return this._reference; | ||
96 | }, | ||
97 | |||
98 | 'setReference': function(aValue) { | ||
99 | this._reference = aValue; | ||
100 | }, | ||
101 | |||
102 | //------------------------------------------------------------------------- | ||
103 | |||
104 | 'key': function() { | ||
105 | //MochiKit.Logging.logDebug(">>> RecordVersion.key"); | ||
106 | //MochiKit.Logging.logDebug("--- RecordVersion.key - " + this._key); | ||
107 | return this._key; | ||
108 | }, | ||
109 | |||
110 | 'setKey': function(aValue) { | ||
111 | this._key = aValue; | ||
112 | }, | ||
113 | |||
114 | //------------------------------------------------------------------------- | ||
115 | |||
116 | 'serverData': function() { | ||
117 | return this._serverData; | ||
118 | }, | ||
119 | |||
120 | 'setServerData': function(aValue) { | ||
121 | this._serverData = aValue; | ||
122 | this.setShouldLoadData(false); | ||
123 | return aValue; | ||
124 | }, | ||
125 | |||
126 | //------------------------------------------------------------------------- | ||
127 | |||
128 | 'decryptedData': function() { | ||
129 | //MochiKit.Logging.logDebug(">>> RecordVersion.decryptedData: " + (this._decryptedData ? Clipperz.Base.serializeJSON(aValue) : "null")); | ||
130 | return this._decryptedData; | ||
131 | }, | ||
132 | |||
133 | 'setDecryptedData': function(aValue) { | ||
134 | //MochiKit.Logging.logDebug(">>> RecordVersion.setDecryptedData: " + Clipperz.Base.serializeJSON(aValue)); | ||
135 | this._decryptedData = aValue; | ||
136 | this.setShouldDecryptData(false); | ||
137 | return aValue; | ||
138 | }, | ||
139 | |||
140 | //------------------------------------------------------------------------- | ||
141 | |||
142 | 'version': function() { | ||
143 | return this._version; | ||
144 | }, | ||
145 | |||
146 | //------------------------------------------------------------------------- | ||
147 | |||
148 | 'isBrandNew': function() { | ||
149 | return this._isBrandNew; | ||
150 | }, | ||
151 | |||
152 | 'setIsBrandNew': function(aValue) { | ||
153 | this._isBrandNew = aValue; | ||
154 | }, | ||
155 | |||
156 | //------------------------------------------------------------------------- | ||
157 | |||
158 | 'fields': function() { | ||
159 | return this._fields; | ||
160 | }, | ||
161 | |||
162 | 'addField': function(aField) { | ||
163 | this.fields()[aField.key()] = aField; | ||
164 | }, | ||
165 | |||
166 | 'addNewField': function() { | ||
167 | varnewRecordField; | ||
168 | |||
169 | newRecordField = new Clipperz.PM.DataModel.RecordField({recordVersion:this}); | ||
170 | this.addField(newRecordField); | ||
171 | |||
172 | return newRecordField; | ||
173 | }, | ||
174 | |||
175 | 'fieldWithName': function(aValue) { | ||
176 | varresult; | ||
177 | var fieldValues; | ||
178 | var i,c; | ||
179 | |||
180 | result = null; | ||
181 | fieldValues = MochiKit.Base.values(this.fields()); | ||
182 | c = fieldValues.length; | ||
183 | for (i=0; (i<c) && (result == null); i++) { | ||
184 | varcurrentField; | ||
185 | |||
186 | currentField = fieldValues[i]; | ||
187 | if (currentField.label() == aValue) { | ||
188 | result = currentField; | ||
189 | } | ||
190 | } | ||
191 | |||
192 | return result; | ||
193 | }, | ||
194 | |||
195 | //------------------------------------------------------------------------- | ||
196 | |||
197 | 'shouldLoadData': function() { | ||
198 | return this._shouldLoadData; | ||
199 | }, | ||
200 | |||
201 | 'setShouldLoadData': function(aValue) { | ||
202 | this._shouldLoadData = aValue; | ||
203 | }, | ||
204 | |||
205 | //------------------------------------------------------------------------- | ||
206 | |||
207 | 'shouldDecryptData': function() { | ||
208 | return this._shouldDecryptData; | ||
209 | }, | ||
210 | |||
211 | 'setShouldDecryptData': function(aValue) { | ||
212 | this._shouldDecryptData = aValue; | ||
213 | }, | ||
214 | |||
215 | //------------------------------------------------------------------------- | ||
216 | |||
217 | 'shouldProcessData': function() { | ||
218 | return this._shouldProcessData; | ||
219 | }, | ||
220 | |||
221 | 'setShouldProcessData': function(aValue) { | ||
222 | this._shouldProcessData = aValue; | ||
223 | }, | ||
224 | |||
225 | //------------------------------------------------------------------------- | ||
226 | |||
227 | 'deferredData': function() { | ||
228 | var deferredResult; | ||
229 | |||
230 | //MochiKit.Logging.logDebug(">>> RecordVersion.deferredData - this: " + this); | ||
231 | deferredResult = new MochiKit.Async.Deferred(); | ||
232 | deferredResult.addCallback(MochiKit.Base.method(this, 'loadData')); | ||
233 | deferredResult.addCallback(MochiKit.Base.method(this, 'decryptData')); | ||
234 | deferredResult.addCallback(MochiKit.Base.method(this, 'processData')); | ||
235 | deferredResult.callback(); | ||
236 | //MochiKit.Logging.logDebug("<<< RecordVersion.deferredData"); | ||
237 | |||
238 | return deferredResult; | ||
239 | }, | ||
240 | |||
241 | //------------------------------------------------------------------------- | ||
242 | |||
243 | 'loadData': function() { | ||
244 | var result; | ||
245 | |||
246 | //MochiKit.Logging.logDebug(">>> RecordVersion.loadData - this: " + this); | ||
247 | if (this.shouldLoadData()) { | ||
248 | var deferredResult; | ||
249 | |||
250 | alert("ERROR: this should have not happened yet!"); | ||
251 | //MochiKit.Logging.logDebug("--- RecordVersion.loadData - 1"); | ||
252 | deferredResult = new MochiKit.Async.Deferred(); | ||
253 | //MochiKit.Logging.logDebug("--- RecordVersion.loadData - 2"); | ||
254 | deferredResult.addCallback(MochiKit.Base.method(this, 'notify'), 'loadingRecordVersionData'); | ||
255 | //MochiKit.Logging.logDebug("--- RecordVersion.loadData - 3"); | ||
256 | deferredResult.addCallback(MochiKit.Base.method(this.user().connection(), 'message'), 'getRecordVersionDetail', {reference: this.reference()}); | ||
257 | //MochiKit.Logging.logDebug("--- RecordVersion.loadData - 4"); | ||
258 | deferredResult.addCallback(MochiKit.Base.method(this, 'setServerData')); | ||
259 | //MochiKit.Logging.logDebug("--- RecordVersion.loadData - 5"); | ||
260 | deferredResult.callback(); | ||
261 | //MochiKit.Logging.logDebug("--- RecordVersion.loadData - 6"); | ||
262 | result = deferredResult; | ||
263 | //MochiKit.Logging.logDebug("--- RecordVersion.loadData - 7"); | ||
264 | } else { | ||
265 | //MochiKit.Logging.logDebug("--- RecordVersion.loadData - 8"); | ||
266 | result = MochiKit.Async.succeed(this.serverData()); | ||
267 | //MochiKit.Logging.logDebug("--- RecordVersion.loadData - 9"); | ||
268 | } | ||
269 | //MochiKit.Logging.logDebug("<<< RecordVersion.loadData"); | ||
270 | |||
271 | return result; | ||
272 | }, | ||
273 | |||
274 | //------------------------------------------------------------------------- | ||
275 | |||
276 | 'decryptData': function(anEncryptedData) { | ||
277 | var result; | ||
278 | |||
279 | //MochiKit.Logging.logDebug(">>> RecordVersion.decryptData - this: " + this + " (" + anEncryptedData + ")"); | ||
280 | if (this.shouldDecryptData()) { | ||
281 | var deferredResult; | ||
282 | |||
283 | //MochiKit.Logging.logDebug("--- RecordVersion.decryptData - 1"); | ||
284 | deferredResult = new MochiKit.Async.Deferred(); | ||
285 | //MochiKit.Logging.logDebug("--- RecordVersion.decryptData - 2"); | ||
286 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("RecordVersion.decryptData 1: " + res); return res;}); | ||
287 | deferredResult.addCallback(MochiKit.Base.method(this, 'notify'), 'decryptingRecordVersionData'); | ||
288 | //MochiKit.Logging.logDebug("--- RecordVersion.decryptData - 3"); | ||
289 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("RecordVersion.decryptData 2: " + res); return res;}); | ||
290 | deferredResult.addCallback(Clipperz.PM.Crypto.deferredDecrypt, this.key(), anEncryptedData, this.version()); | ||
291 | //MochiKit.Logging.logDebug("--- RecordVersion.decryptData - 4"); | ||
292 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("RecordVersion.decryptData 3: " + res); return res;}); | ||
293 | //MochiKit.Logging.logDebug("--- RecordVersion.decryptData - 5"); | ||
294 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("RecordVersion.decryptData 4: " + res); return res;}); | ||
295 | deferredResult.addCallback(MochiKit.Base.method(this, 'setDecryptedData')); | ||
296 | //MochiKit.Logging.logDebug("--- RecordVersion.decryptData - 6"); | ||
297 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("RecordVersion.decryptData 5: " + res); return res;}); | ||
298 | deferredResult.callback(); | ||
299 | //MochiKit.Logging.logDebug("--- RecordVersion.decryptData - 7"); | ||
300 | result = deferredResult; | ||
301 | //MochiKit.Logging.logDebug("--- RecordVersion.decryptData - 8"); | ||
302 | } else { | ||
303 | //MochiKit.Logging.logDebug("--- RecordVersion.decryptData - 9"); | ||
304 | result = MochiKit.Async.succeed(this.decryptedData()); | ||
305 | //MochiKit.Logging.logDebug("--- RecordVersion.decryptData - 10"); | ||
306 | } | ||
307 | //MochiKit.Logging.logDebug("<<< RecordVersion.decryptData"); | ||
308 | |||
309 | return result; | ||
310 | }, | ||
311 | |||
312 | //------------------------------------------------------------------------- | ||
313 | |||
314 | 'processFieldData': function(someValues) { | ||
315 | var fieldValues; | ||
316 | |||
317 | this._fields = {}; | ||
318 | |||
319 | if (typeof(someValues) == 'undefined') { | ||
320 | fieldValues = {}; | ||
321 | } else { | ||
322 | fieldValues = someValues; | ||
323 | } | ||
324 | |||
325 | if (fieldValues.constructor == Array) { | ||
326 | var i, c; | ||
327 | c = fieldValues.length; | ||
328 | for (i=0; i<c; i++) { | ||
329 | var newRecordField; | ||
330 | var currentFieldValues; | ||
331 | |||
332 | currentFieldValues = fieldValues[i]; | ||
333 | currentFieldValues['recordVersion'] = this; | ||
334 | newRecordField = new Clipperz.PM.DataModel.RecordField(currentFieldValues); | ||
335 | this._fields[newRecordField.key()] = newRecordField; | ||
336 | } | ||
337 | |||
338 | } else { | ||
339 | var fieldKey; | ||
340 | |||
341 | for (fieldKey in fieldValues) { | ||
342 | var newRecordField; | ||
343 | var currentFieldValues; | ||
344 | |||
345 | currentFieldValues = fieldValues[fieldKey]; | ||
346 | currentFieldValues['key'] = fieldKey; | ||
347 | currentFieldValues['recordVersion'] = this; | ||
348 | newRecordField = new Clipperz.PM.DataModel.RecordField(currentFieldValues); | ||
349 | this._fields[fieldKey] = newRecordField; | ||
350 | } | ||
351 | } | ||
352 | |||
353 | }, | ||
354 | |||
355 | 'processData': function(someValues) { | ||
356 | if (this.shouldProcessData()) { | ||
357 | this.processFieldData(someValues.fields); | ||
358 | this.setShouldProcessData(false); | ||
359 | } | ||
360 | |||
361 | this.notify('recordVersionDataReady'); | ||
362 | |||
363 | return this; | ||
364 | }, | ||
365 | |||
366 | //------------------------------------------------------------------------- | ||
367 | |||
368 | 'notify': function(aValue) { | ||
369 | Clipperz.NotificationCenter.notify(this, aValue); | ||
370 | }, | ||
371 | |||
372 | //------------------------------------------------------------------------- | ||
373 | |||
374 | 'removeField': function(aField) { | ||
375 | delete this.fields()[aField.key()]; | ||
376 | }, | ||
377 | |||
378 | //------------------------------------------------------------------------- | ||
379 | |||
380 | 'previousVersion': function() { | ||
381 | return this._previousVersion; | ||
382 | }, | ||
383 | |||
384 | 'setPreviousVersion': function(aValue) { | ||
385 | this._previousVersion = aValue; | ||
386 | }, | ||
387 | |||
388 | //------------------------------------------------------------------------- | ||
389 | |||
390 | 'previousVersionKey': function() { | ||
391 | return this._previousVersionKey; | ||
392 | }, | ||
393 | |||
394 | 'setPreviousVersionKey': function(aValue) { | ||
395 | this._previousVersionKey = aValue; | ||
396 | }, | ||
397 | |||
398 | //------------------------------------------------------------------------- | ||
399 | |||
400 | 'serializedData': function() { | ||
401 | var result; | ||
402 | varfieldKey; | ||
403 | |||
404 | //MochiKit.Logging.logDebug(">>> RecordVersion.serializedData"); | ||
405 | result = { | ||
406 | fields: {} | ||
407 | }; | ||
408 | //MochiKit.Logging.logDebug("--- RecordVersion.serializedData - 1"); | ||
409 | |||
410 | for (fieldKey in this.fields()) { | ||
411 | //MochiKit.Logging.logDebug("--- RecordVersion.serializedData - 2"); | ||
412 | result.fields[fieldKey] = this.fields()[fieldKey].serializeData(); | ||
413 | //MochiKit.Logging.logDebug("--- RecordVersion.serializedData - 3"); | ||
414 | } | ||
415 | //MochiKit.Logging.logDebug("--- RecordVersion.serializedData - 4"); | ||
416 | //MochiKit.Logging.logDebug("<<< RecordVersion.serializedData: " + Clipperz.Base.serializeJSON(result)); | ||
417 | |||
418 | return result; | ||
419 | }, | ||
420 | |||
421 | 'currentDataSnapshot': function() { | ||
422 | var result; | ||
423 | |||
424 | result = this.serializedData(); | ||
425 | result['version'] = this.version(); | ||
426 | result['reference'] = this.reference(); | ||
427 | result['previousVersionKey'] = this.previousVersionKey(); | ||
428 | |||
429 | return result; | ||
430 | }, | ||
431 | |||
432 | //------------------------------------------------------------------------- | ||
433 | |||
434 | 'encryptedData': function() { | ||
435 | var deferredResult; | ||
436 | var result; | ||
437 | |||
438 | //MochiKit.Logging.logDebug(">>> RecordVersion.encryptedData - " + this); | ||
439 | result = {}; | ||
440 | deferredResult = new MochiKit.Async.Deferred(); | ||
441 | //MochiKit.Logging.logDebug("--- RecordVersion.encryptedData - 1"); | ||
442 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("RecordVersion.encryptedData - 1: " + res); return res;}); | ||
443 | deferredResult.addCallback(function(aResult, aRecordVersion) { | ||
444 | aResult['reference'] = aRecordVersion.reference(); | ||
445 | aResult['recordReference'] = aRecordVersion.record().reference();// TODO - this seems to be completely useless | ||
446 | return aResult; | ||
447 | }, result, this); | ||
448 | //MochiKit.Logging.logDebug("--- RecordVersion.encryptedData - 2"); | ||
449 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("RecordVersion.encryptedData - 2: " + res); return res;}); | ||
450 | deferredResult.addCallback(Clipperz.PM.Crypto.deferredEncryptWithCurrentVersion, this.key(), this.serializedData()); | ||
451 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("RecordVersion.encryptedData - 3: " + res); return res;}); | ||
452 | deferredResult.addCallback(function(aResult, res) { | ||
453 | aResult['data'] = res; | ||
454 | return aResult; | ||
455 | }, result); | ||
456 | //MochiKit.Logging.logDebug("--- RecordVersion.encryptedData - 3"); | ||
457 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("RecordVersion.encryptedData - 4: " + res); return res;}); | ||
458 | deferredResult.addCallback(function(aResult) { | ||
459 | aResult['version'] = Clipperz.PM.Crypto.encryptingFunctions.currentVersion; | ||
460 | return aResult; | ||
461 | }, result); | ||
462 | //MochiKit.Logging.logDebug("--- RecordVersion.encryptedData - 4"); | ||
463 | if (this.previousVersion() != null) { | ||
464 | //MochiKit.Logging.logDebug("--- RecordVersion.encryptedData - 5"); | ||
465 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("RecordVersion.encryptedData - 5: " + res); return res;}); | ||
466 | deferredResult.addCallback(function(aResult, aRecordVersion) { | ||
467 | aResult['previousVersion'] = aRecordVersion.previousVersion(); | ||
468 | return aResult; | ||
469 | }, result, this); | ||
470 | //MochiKit.Logging.logDebug("--- RecordVersion.encryptedData - 6"); | ||
471 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("RecordVersion.encryptedData - 6: " + res); return res;}); | ||
472 | deferredResult.addCallback(Clipperz.PM.Crypto.deferredEncryptWithCurrentVersion, this.key(), this.previousVersionKey()); | ||
473 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("RecordVersion.encryptedData - 7: " + res); return res;}); | ||
474 | deferredResult.addCallback(function(aResult, res) { | ||
475 | aResult['previousVersionKey'] = res; | ||
476 | return aResult; | ||
477 | }, result); | ||
478 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("RecordVersion.encryptedData - 8: " + res); return res;}); | ||
479 | //MochiKit.Logging.logDebug("--- RecordVersion.encryptedData - 7"); | ||
480 | } else { | ||
481 | //MochiKit.Logging.logDebug("--- RecordVersion.encryptedData - 8"); | ||
482 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("RecordVersion.encryptedData - 9: " + res); return res;}); | ||
483 | deferredResult.addCallback(function(aResult) { | ||
484 | aResult['previousVersionKey'] = Clipperz.PM.Crypto.nullValue; | ||
485 | return aResult; | ||
486 | }, result); | ||
487 | //MochiKit.Logging.logDebug("--- RecordVersion.encryptedData - 9"); | ||
488 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("RecordVersion.encryptedData - 10: " + res); return res;}); | ||
489 | }; | ||
490 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("RecordVersion.encryptedData - 11: " + res); return res;}); | ||
491 | deferredResult.callback(); | ||
492 | //MochiKit.Logging.logDebug("<<< RecordVersion.encryptedData"); | ||
493 | |||
494 | return deferredResult; | ||
495 | }, | ||
496 | |||
497 | //------------------------------------------------------------------------- | ||
498 | |||
499 | 'createNewVersion': function() { | ||
500 | if (this.record().isBrandNew() == false) { | ||
501 | this.setPreviousVersion(this.reference()); | ||
502 | this.setPreviousVersionKey(this.key()); | ||
503 | |||
504 | this.setReference(Clipperz.PM.Crypto.randomKey()); | ||
505 | this.setKey(Clipperz.PM.Crypto.randomKey()); | ||
506 | } | ||
507 | }, | ||
508 | |||
509 | //------------------------------------------------------------------------- | ||
510 | /* | ||
511 | 'shouldLoadData': function() { | ||
512 | return ((this.data() == null) && (this.isBrandNew() === false)); | ||
513 | }, | ||
514 | |||
515 | 'loadData': function() { | ||
516 | //MochiKit.Logging.logDebug(">>> Record.loadData (" + this.label() + ")"); | ||
517 | // if (this.shouldLoadData()) { | ||
518 | // this.user().connection().message('getRecordDetail', | ||
519 | // {recordReference: this.reference()}, | ||
520 | // {callback:MochiKit.Base.bind(this.loadDataCallback, this), | ||
521 | // errorHandler:Clipperz.PM.defaultErrorHandler }); | ||
522 | // } else { | ||
523 | // this.notify('loadDataDone'); | ||
524 | // } | ||
525 | }, | ||
526 | |||
527 | 'loadDataCallback': function() { | ||
528 | MochiKit.Logging.logDebug("RecordVersion.loadDataCallback: " + Clipperz.Base.serializeJSON(arguments)); | ||
529 | }, | ||
530 | */ | ||
531 | //------------------------------------------------------------------------- | ||
532 | __syntaxFix__: "syntax fix" | ||
533 | |||
534 | }); | ||
535 | |||