Diffstat (limited to 'frontend/gamma/js/Clipperz/PM/DataModel/User.Header.Legacy.js') (more/less context) (ignore whitespace changes)
-rw-r--r-- | frontend/gamma/js/Clipperz/PM/DataModel/User.Header.Legacy.js | 187 |
1 files changed, 187 insertions, 0 deletions
diff --git a/frontend/gamma/js/Clipperz/PM/DataModel/User.Header.Legacy.js b/frontend/gamma/js/Clipperz/PM/DataModel/User.Header.Legacy.js new file mode 100644 index 0000000..e675525 --- a/dev/null +++ b/frontend/gamma/js/Clipperz/PM/DataModel/User.Header.Legacy.js | |||
@@ -0,0 +1,187 @@ | |||
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 | try { if (typeof(Clipperz.PM.DataModel.User) == 'undefined') { throw ""; }} catch (e) { | ||
30 | throw "Clipperz.PM.DataModel.User.Header.Legacy depends on Clipperz.PM.DataModel.User!"; | ||
31 | } | ||
32 | |||
33 | if (typeof(Clipperz.PM.DataModel.User.Header) == 'undefined') { Clipperz.PM.DataModel.User.Header = {}; } | ||
34 | |||
35 | Clipperz.PM.DataModel.User.Header.Legacy = function(args) { | ||
36 | //args = args || {}; | ||
37 | Clipperz.PM.DataModel.User.Header.Legacy.superclass.constructor.apply(this, arguments); | ||
38 | |||
39 | this._retrieveRecordDetailFunction = args.retrieveRecordDetailFunction|| Clipperz.Base.exception.raise('MandatoryParameter'); | ||
40 | this._records = null; | ||
41 | //this._directLogins = null; | ||
42 | |||
43 | return this; | ||
44 | } | ||
45 | |||
46 | |||
47 | Clipperz.Base.extend(Clipperz.PM.DataModel.User.Header.Legacy, Clipperz.PM.DataModel.EncryptedRemoteObject, { | ||
48 | |||
49 | 'toString': function() { | ||
50 | return "Clipperz.PM.DataModel.User.Header.Legacy"; | ||
51 | }, | ||
52 | |||
53 | //------------------------------------------------------------------------- | ||
54 | |||
55 | 'retrieveRecordDetailFunction': function () { | ||
56 | return this._retrieveRecordDetailFunction; | ||
57 | }, | ||
58 | |||
59 | //------------------------------------------------------------------------- | ||
60 | |||
61 | 'getRecordKey': function (aRecordReference) { | ||
62 | var deferredResult; | ||
63 | |||
64 | deferredResult = new Clipperz.Async.Deferred("User.Header.Legacy.getRecordKey", {trace:false}); | ||
65 | deferredResult.addMethod(this, 'getRecordIndexData'); | ||
66 | deferredResult.addCallback(MochiKit.Base.itemgetter('key')) | ||
67 | deferredResult.callback(); | ||
68 | |||
69 | return deferredResult; | ||
70 | }, | ||
71 | |||
72 | //========================================================================= | ||
73 | |||
74 | 'getRecordIndexData': function (aRecordReference) { | ||
75 | return this.getValue('records.' + aRecordReference); | ||
76 | }, | ||
77 | |||
78 | 'updateRecordIndexData': function (aRecordReference, aKey, aValue) { | ||
79 | return this.setValue('records.' + aRecordReference + "." + aKey, aValue); | ||
80 | }, | ||
81 | |||
82 | //------------------------------------------------------------------------- | ||
83 | |||
84 | 'getDirectLoginIndexData': function (aDirectLoginReference) { | ||
85 | return this.getValue('directLogins.' + aDirectLoginReference); | ||
86 | }, | ||
87 | |||
88 | 'setDirectLoginIndexData': function (aDirectLoginReference, aKey, aValue) { | ||
89 | return this.setValue('directLogins.' + aDirectLoginReference + '.' + aKey, aValue); | ||
90 | }, | ||
91 | |||
92 | 'removeDirectLoginIndexData': function (aDirectLoginReference) { | ||
93 | return this.removeValue('directLogins.' + aDirectLoginReference); | ||
94 | }, | ||
95 | |||
96 | //========================================================================= | ||
97 | |||
98 | 'records': function () { | ||
99 | vardeferredResult; | ||
100 | var deferredLock; | ||
101 | |||
102 | deferredLock = this.getDeferredLockForKey('records'); | ||
103 | |||
104 | deferredResult = new Clipperz.Async.Deferred("User.Header.Legacy.records", {trace:false}); | ||
105 | deferredResult.acquireLock(deferredLock); | ||
106 | deferredResult.addCallback(MochiKit.Base.bind(function () { | ||
107 | var innerDeferredResult; | ||
108 | |||
109 | if (this._records == null) { | ||
110 | innerDeferredResult = new Clipperz.Async.Deferred("User.Header.Legacy.records <inner deferred>", {trace:false}); | ||
111 | innerDeferredResult.collectResults({ | ||
112 | 'header': [ | ||
113 | // MochiKit.Base.method(this, 'getObjectDataStore'), | ||
114 | // MochiKit.Base.methodcaller('values') | ||
115 | MochiKit.Base.method(this, 'values') | ||
116 | ], | ||
117 | 'recordsStats': [ | ||
118 | MochiKit.Base.method(this, 'getRemoteData'), | ||
119 | MochiKit.Base.itemgetter('recordsStats') | ||
120 | ] | ||
121 | }); | ||
122 | innerDeferredResult.addCallback(MochiKit.Base.bind(function (someObjectData) { | ||
123 | var reference; | ||
124 | |||
125 | this._records = {}; | ||
126 | // this._directLogins = {}; | ||
127 | |||
128 | for (reference in someObjectData['header']['records']) { | ||
129 | varrecord; | ||
130 | |||
131 | record = new Clipperz.PM.DataModel.Record({ | ||
132 | 'reference': reference, | ||
133 | 'retrieveKeyFunction': MochiKit.Base.method(this, 'getRecordKey'), | ||
134 | 'retrieveRemoteDataFunction':this.retrieveRecordDetailFunction(), | ||
135 | // 'encryptedDataKeypath': 'data', | ||
136 | // 'encryptedVersionKeypath': 'version', | ||
137 | |||
138 | 'retrieveIndexDataFunction':MochiKit.Base.method(this, 'getRecordIndexData'), | ||
139 | 'updateIndexDataFunction': MochiKit.Base.method(this, 'updateRecordIndexData'), | ||
140 | 'updateDate': someObjectData['recordsStats'][reference]['updateDate'], | ||
141 | |||
142 | 'retrieveDirectLoginIndexDataFunction':MochiKit.Base.method(this, 'getDirectLoginIndexData'), | ||
143 | 'setDirectLoginIndexDataFunction': MochiKit.Base.method(this, 'setDirectLoginIndexData'), | ||
144 | 'removeDirectLoginIndexDataFunction':MochiKit.Base.method(this, 'removeDirectLoginIndexData') | ||
145 | }); | ||
146 | |||
147 | this._records[reference] = record; | ||
148 | } | ||
149 | |||
150 | for (reference in someObjectData['header']['directLogins']) { | ||
151 | vardirectLogin; | ||
152 | var record; | ||
153 | |||
154 | record = this._records[someObjectData['header']['directLogins'][reference]['record']]; | ||
155 | if (record != null) { | ||
156 | directLogin = new Clipperz.PM.DataModel.DirectLogin({ | ||
157 | 'reference': reference, | ||
158 | 'record': record//, | ||
159 | // 'retrieveIndexDataFunction':MochiKit.Base.method(this, 'getDirectLoginIndexData'), | ||
160 | // 'setIndexDataFunction': MochiKit.Base.method(this, 'setDirectLoginIndexData'), | ||
161 | // 'removeIndexDataFunction': MochiKit.Base.method(this, 'removeDirectLoginIndexData') | ||
162 | }); | ||
163 | } else { | ||
164 | Clipperz.log("WARNING: DIRECT LOGIN without a matching RECORD!!"); | ||
165 | } | ||
166 | } | ||
167 | |||
168 | return this._records; | ||
169 | }, this)); | ||
170 | innerDeferredResult.callback(); | ||
171 | } else { | ||
172 | innerDeferredResult = MochiKit.Async.succeed(this._records); | ||
173 | } | ||
174 | |||
175 | return innerDeferredResult; | ||
176 | }, this)); | ||
177 | deferredResult.releaseLock(deferredLock); | ||
178 | deferredResult.callback(); | ||
179 | |||
180 | return deferredResult; | ||
181 | }, | ||
182 | |||
183 | //========================================================================= | ||
184 | __syntaxFix__: "syntax fix" | ||
185 | }); | ||
186 | |||
187 | |||