Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
officejs
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
officejs
Commits
dfebe7c8
Commit
dfebe7c8
authored
Aug 21, 2012
by
Tristan Cavelier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix bug: storages can now use jobManager correctly
parent
8b66f91e
Changes
17
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
309 additions
and
240 deletions
+309
-240
OfficeJS/grunt/10_gruntJIO/grunt.js
OfficeJS/grunt/10_gruntJIO/grunt.js
+1
-2
OfficeJS/src/jio.storage/conflictmanagerstorage.js
OfficeJS/src/jio.storage/conflictmanagerstorage.js
+4
-3
OfficeJS/src/jio.storage/cryptstorage.js
OfficeJS/src/jio.storage/cryptstorage.js
+2
-1
OfficeJS/src/jio.storage/davstorage.js
OfficeJS/src/jio.storage/davstorage.js
+17
-11
OfficeJS/src/jio.storage/indexstorage.js
OfficeJS/src/jio.storage/indexstorage.js
+2
-1
OfficeJS/src/jio.storage/localstorage.js
OfficeJS/src/jio.storage/localstorage.js
+6
-5
OfficeJS/src/jio.storage/replicatestorage.js
OfficeJS/src/jio.storage/replicatestorage.js
+2
-1
OfficeJS/src/jio/intro.js
OfficeJS/src/jio/intro.js
+1
-0
OfficeJS/src/jio/jio.intro.js
OfficeJS/src/jio/jio.intro.js
+1
-1
OfficeJS/src/jio/jio.outro.js
OfficeJS/src/jio/jio.outro.js
+155
-97
OfficeJS/src/jio/jioNamespace.js
OfficeJS/src/jio/jioNamespace.js
+25
-38
OfficeJS/src/jio/jobs/job.js
OfficeJS/src/jio/jobs/job.js
+6
-7
OfficeJS/src/jio/jobs/jobIdHandler.js
OfficeJS/src/jio/jobs/jobIdHandler.js
+1
-2
OfficeJS/src/jio/jobs/jobManager.js
OfficeJS/src/jio/jobs/jobManager.js
+4
-8
OfficeJS/src/jio/jobs/jobRules.js
OfficeJS/src/jio/jobs/jobRules.js
+46
-21
OfficeJS/src/jio/storages/storage.js
OfficeJS/src/jio/storages/storage.js
+36
-9
OfficeJS/src/jio/storages/storageHandler.js
OfficeJS/src/jio/storages/storageHandler.js
+0
-33
No files found.
OfficeJS/grunt/10_gruntJIO/grunt.js
View file @
dfebe7c8
...
...
@@ -18,8 +18,8 @@ module.exports = function(grunt) {
'
<file_strip_banner:../../src/<%= pkg.name %>/intro.js>
'
,
'
<file_strip_banner:../../src/<%= pkg.name %>/exceptions.js>
'
,
// Jio wrapper top
'
<file_strip_banner:../../src/<%= pkg.name %>/jio.intro.js>
'
,
'
<file_strip_banner:../../src/<%= pkg.name %>/storages/storage.js>
'
,
'
<file_strip_banner:../../src/<%= pkg.name %>/storages/storageHandler.js>
'
,
'
<file_strip_banner:../../src/<%= pkg.name %>/commands/command.js>
'
,
'
<file_strip_banner:../../src/<%= pkg.name %>/commands/allDocsCommand.js>
'
,
'
<file_strip_banner:../../src/<%= pkg.name %>/commands/getCommand.js>
'
,
...
...
@@ -34,7 +34,6 @@ module.exports = function(grunt) {
'
<file_strip_banner:../../src/<%= pkg.name %>/jobs/status/waitStatus.js>
'
,
'
<file_strip_banner:../../src/<%= pkg.name %>/jobs/job.js>
'
,
'
<file_strip_banner:../../src/<%= pkg.name %>/announcements/announcement.js>
'
,
'
<file_strip_banner:../../src/<%= pkg.name %>/jio.intro.js>
'
,
// Singletons
'
<file_strip_banner:../../src/<%= pkg.name %>/activityUpdater.js>
'
,
'
<file_strip_banner:../../src/<%= pkg.name %>/announcements/announcer.js>
'
,
...
...
OfficeJS/src/jio.storage/conflictmanagerstorage.js
View file @
dfebe7c8
var
newConflictManagerStorage
=
function
(
spec
,
my
)
{
var
that
=
Jio
.
storage
(
spec
,
my
,
'
handler
'
),
priv
=
{};
spec
=
spec
||
{};
my
=
my
||
{};
var
that
=
my
.
basicStorage
(
spec
,
my
),
priv
=
{};
var
storage_exists
=
(
spec
.
storage
?
true
:
false
);
priv
.
secondstorage_spec
=
spec
.
storage
||
{
type
:
'
base
'
};
...
...
@@ -42,7 +41,7 @@ var newConflictManagerStorage = function ( spec, my ) {
};
priv
.
saveNewRevision
=
function
(
command
,
path
,
content
,
success
,
error
)
{
that
.
addJob
(
'
p
u
t
'
,
priv
.
secondstorage_spec
,{
_id
:
path
,
content
:
content
},
that
.
addJob
(
'
p
os
t
'
,
priv
.
secondstorage_spec
,{
_id
:
path
,
content
:
content
},
command
.
cloneOption
(),
success
,
error
);
};
...
...
@@ -72,6 +71,7 @@ var newConflictManagerStorage = function ( spec, my ) {
};
priv
.
_revs
=
function
(
metadata
,
revision
)
{
if
(
!
(
metadata
&&
revision
))
{
return
null
;
}
if
(
metadata
[
revision
])
{
return
{
start
:
metadata
[
revision
].
_revisions
.
length
,
ids
:
metadata
[
revision
].
_revisions
};
...
...
@@ -81,6 +81,7 @@ var newConflictManagerStorage = function ( spec, my ) {
};
priv
.
_revs_info
=
function
(
metadata
)
{
if
(
!
metadata
)
{
return
null
;
}
var
k
,
l
=
[];
for
(
k
in
metadata
)
{
l
.
push
({
...
...
OfficeJS/src/jio.storage/cryptstorage.js
View file @
dfebe7c8
var
newCryptedStorage
=
function
(
spec
,
my
)
{
var
that
=
Jio
.
storage
(
spec
,
my
,
'
handler
'
),
priv
=
{};
spec
=
spec
||
{};
var
that
=
my
.
basicStorage
(
spec
,
my
),
priv
=
{};
var
is_valid_storage
=
(
spec
.
storage
?
true
:
false
);
...
...
OfficeJS/src/jio.storage/davstorage.js
View file @
dfebe7c8
var
newDAVStorage
=
function
(
spec
,
my
)
{
var
that
=
Jio
.
storage
(
spec
,
my
,
'
base
'
),
priv
=
{};
spec
=
spec
||
{};
var
that
=
my
.
basicStorage
(
spec
,
my
),
priv
=
{};
priv
.
secureDocId
=
function
(
string
)
{
var
split
=
string
.
split
(
'
/
'
),
i
;
...
...
@@ -75,15 +76,7 @@ var newDAVStorage = function ( spec, my ) {
return
async
;
};
that
.
post
=
function
(
command
)
{
that
.
put
(
command
);
};
/**
* Saves a document in the distant dav storage.
* @method put
*/
that
.
put
=
function
(
command
)
{
priv
.
putOrPost
=
function
(
command
,
type
)
{
var
secured_docid
=
priv
.
secureDocId
(
command
.
getDocId
());
...
...
@@ -92,7 +85,7 @@ var newDAVStorage = function ( spec, my ) {
priv
.
secured_username
+
'
/
'
+
priv
.
secured_applicationname
+
'
/
'
+
secured_docid
,
type
:
'
PUT
'
,
type
:
type
,
data
:
command
.
getDocContent
(),
async
:
true
,
dataType
:
'
text
'
,
// TODO is it necessary ?
...
...
@@ -110,6 +103,18 @@ var newDAVStorage = function ( spec, my ) {
that
.
retry
(
type
);
}
}
);
};
that
.
post
=
function
(
command
)
{
priv
.
putOrPost
(
command
,
'
POST
'
);
};
/**
* Saves a document in the distant dav storage.
* @method put
*/
that
.
put
=
function
(
command
)
{
priv
.
putOrPost
(
command
,
'
PUT
'
);
};
// end put
/**
...
...
@@ -247,6 +252,7 @@ var newDAVStorage = function ( spec, my ) {
dataType
:
'
xml
'
,
headers
:
{
'
Authorization
'
:
'
Basic
'
+
Base64
.
encode
(
priv
.
username
+
'
:
'
+
priv
.
password
),
Depth
:
'
1
'
},
// xhrFields: {withCredentials: 'true'}, // cross domain
success
:
function
(
xmlData
)
{
var
response
=
$
(
xmlData
).
find
(
'
D
\\
:response, response
'
...
...
OfficeJS/src/jio.storage/indexstorage.js
View file @
dfebe7c8
var
newIndexStorage
=
function
(
spec
,
my
)
{
var
that
=
Jio
.
storage
(
spec
,
my
,
'
handler
'
),
priv
=
{};
spec
=
spec
||
{};
var
that
=
my
.
basicStorage
(
spec
,
my
),
priv
=
{};
var
validatestate_secondstorage
=
spec
.
storage
||
false
;
priv
.
secondstorage_spec
=
spec
.
storage
||
{
type
:
'
base
'
};
...
...
OfficeJS/src/jio.storage/localstorage.js
View file @
dfebe7c8
...
...
@@ -3,7 +3,8 @@
* It is a database located in the browser local storage.
*/
var
newLocalStorage
=
function
(
spec
,
my
)
{
var
that
=
Jio
.
storage
(
spec
,
my
,
'
base
'
),
priv
=
{};
spec
=
spec
||
{};
var
that
=
my
.
basicStorage
(
spec
,
my
),
priv
=
{};
priv
.
secureDocId
=
function
(
string
)
{
var
split
=
string
.
split
(
'
/
'
),
i
;
...
...
@@ -179,7 +180,7 @@ var newLocalStorage = function ( spec, my ) {
}
LocalOrCookieStorage
.
setItem
(
path
,
doc
);
that
.
success
({
ok
:
true
,
id
:
command
.
getDocId
()});
});
}
,
5000
);
};
// end put
/**
...
...
@@ -213,7 +214,7 @@ var newLocalStorage = function ( spec, my ) {
}
that
.
success
(
doc
);
}
});
}
,
5000
);
};
// end get
/**
...
...
@@ -249,7 +250,7 @@ var newLocalStorage = function ( spec, my ) {
}
}
that
.
success
({
total_rows
:
new_array
.
length
,
rows
:
new_array
});
});
}
,
5000
);
};
// end allDocs
/**
...
...
@@ -270,7 +271,7 @@ var newLocalStorage = function ( spec, my ) {
LocalOrCookieStorage
.
deleteItem
(
path
);
priv
.
removeFileName
(
secured_docid
);
that
.
success
({
ok
:
true
,
id
:
command
.
getDocId
()});
});
}
,
5000
);
};
// end remove
return
that
;
...
...
OfficeJS/src/jio.storage/replicatestorage.js
View file @
dfebe7c8
var
newReplicateStorage
=
function
(
spec
,
my
)
{
var
that
=
Jio
.
storage
(
spec
,
my
,
'
handler
'
),
priv
=
{};
spec
=
spec
||
{};
var
that
=
my
.
basicStorage
(
spec
,
my
),
priv
=
{};
priv
.
return_value_array
=
[];
priv
.
storagelist
=
spec
.
storagelist
||
[];
...
...
OfficeJS/src/jio/intro.js
View file @
dfebe7c8
var
jio
=
(
function
()
{
"
use strict
"
;
OfficeJS/src/jio/jio.intro.js
View file @
dfebe7c8
var
jio
=
function
(
spec
,
my
)
{
var
jio
=
function
(
spec
)
{
OfficeJS/src/jio/jio.outro.js
View file @
dfebe7c8
This diff is collapsed.
Click to expand it.
OfficeJS/src/jio/jioNamespace.js
View file @
dfebe7c8
var
jioNamespace
=
(
function
(
spec
,
my
)
{
var
storage_type_object
=
{
// -> 'key':constructorFunction
'
base
'
:
function
()
{}
// overidden by jio
};
var
jioNamespace
=
(
function
(
spec
)
{
var
that
=
{};
spec
=
spec
||
{};
my
=
my
||
{};
// Attributes //
var
storage_type_o
=
{
// -> 'key':constructorFunction
'
base
'
:
storage
,
'
handler
'
:
storageHandler
};
// Methods //
/**
* Returns a storage from a storage description.
* @method storage
* @param {object} spec The specifications.
* @param {object} my The protected object.
* @param {string} forcetype Force storage type
* @return {object} The storage object.
*/
that
.
storage
=
function
(
spec
,
my
,
forcetype
)
{
spec
=
spec
||
{};
my
=
my
||
{};
var
type
=
forcetype
||
spec
.
type
||
'
base
'
;
if
(
!
storage_type_o
[
type
])
{
throw
invalidStorageType
({
type
:
type
,
message
:
'
Storage does not exists.
'
});
}
return
storage_type_o
[
type
](
spec
,
my
);
};
/**
* Creates a new jio instance.
* @method newJio
...
...
@@ -39,14 +18,19 @@ var jioNamespace = (function(spec, my) {
* - {string} spec.storage.applicationname: The application name
* @return {object} The new Jio instance.
*/
that
.
newJio
=
function
(
spec
)
{
var
storage
=
spec
;
if
(
typeof
storage
===
'
string
'
)
{
storage
=
JSON
.
parse
(
storage
);
Object
.
defineProperty
(
that
,
"
newJio
"
,{
configurable
:
false
,
enumerable
:
false
,
writable
:
false
,
value
:
function
(
spec
)
{
var
storage
=
spec
,
instance
=
null
;
if
(
typeof
storage
===
'
string
'
)
{
storage
=
JSON
.
parse
(
storage
);
}
storage
=
storage
||
{
type
:
'
base
'
};
instance
=
jio
(
spec
);
instance
.
start
();
return
instance
;
}
storage
=
storage
||
{
type
:
'
base
'
};
return
jio
(
spec
);
};
});
/**
* Add a storage type to jio.
...
...
@@ -54,13 +38,16 @@ var jioNamespace = (function(spec, my) {
* @param {string} type The storage type
* @param {function} constructor The associated constructor
*/
that
.
addStorageType
=
function
(
type
,
constructor
)
{
constructor
=
constructor
||
function
(){
return
null
;};
if
(
storage_type_o
[
type
])
{
throw
invalidStorageType
({
type
:
type
,
message
:
'
Already known.
'
});
Object
.
defineProperty
(
that
,
"
addStorageType
"
,{
configurable
:
false
,
enumerable
:
false
,
writable
:
false
,
value
:
function
(
type
,
constructor
)
{
constructor
=
constructor
||
function
(){
return
null
;};
if
(
storage_type_object
[
type
])
{
throw
invalidStorageType
({
type
:
type
,
message
:
'
Already known.
'
});
}
storage_type_object
[
type
]
=
constructor
;
}
storage_type_o
[
type
]
=
constructor
;
};
});
return
that
;
}());
OfficeJS/src/jio/jobs/job.js
View file @
dfebe7c8
var
job
=
function
(
spec
,
my
)
{
var
job
=
function
(
spec
)
{
var
that
=
{};
spec
=
spec
||
{};
my
=
my
||
{};
// Attributes //
var
priv
=
{};
priv
.
id
=
my
.
jobIdHandler
.
nextId
();
priv
.
id
=
jobIdHandler
.
nextId
();
priv
.
command
=
spec
.
command
;
priv
.
storage
=
spec
.
storage
;
priv
.
status
=
initialStatus
();
...
...
@@ -76,7 +75,7 @@ var job = function(spec, my) {
*/
that
.
waitForJob
=
function
(
job
)
{
if
(
priv
.
status
.
getLabel
()
!==
'
wait
'
)
{
priv
.
status
=
waitStatus
({}
,
my
);
priv
.
status
=
waitStatus
({});
}
priv
.
status
.
waitForJob
(
job
);
};
...
...
@@ -99,7 +98,7 @@ var job = function(spec, my) {
*/
that
.
waitForTime
=
function
(
ms
)
{
if
(
priv
.
status
.
getLabel
()
!==
'
wait
'
)
{
priv
.
status
=
waitStatus
({}
,
my
);
priv
.
status
=
waitStatus
({});
}
priv
.
status
.
waitForTime
(
ms
);
};
...
...
@@ -124,7 +123,7 @@ var job = function(spec, my) {
that
.
notAccepted
=
function
()
{
priv
.
command
.
onEndDo
(
function
()
{
priv
.
status
=
failStatus
();
my
.
jobManager
.
terminateJob
(
that
);
jobManager
.
terminateJob
(
that
);
});
priv
.
command
.
error
({
status
:
11
,
statusText
:
'
Not Accepted
'
,
error
:
'
not_accepted
'
,
...
...
@@ -171,7 +170,7 @@ var job = function(spec, my) {
});
priv
.
command
.
onEndDo
(
function
(
status
)
{
priv
.
status
=
status
;
my
.
jobManager
.
terminateJob
(
that
);
jobManager
.
terminateJob
(
that
);
});
priv
.
command
.
execute
(
priv
.
storage
);
};
...
...
OfficeJS/src/jio/jobs/jobIdHandler.js
View file @
dfebe7c8
var
jobIdHandler
=
(
function
(
spec
,
my
)
{
var
jobIdHandler
=
(
function
(
spec
)
{
var
that
=
{};
spec
=
spec
||
{};
my
=
my
||
{};
// Attributes //
var
id
=
0
;
// Methods //
...
...
OfficeJS/src/jio/jobs/jobManager.js
View file @
dfebe7c8
var
jobManager
=
(
function
(
spec
,
my
)
{
var
jobManager
=
(
function
(
spec
)
{
var
that
=
{};
spec
=
spec
||
{};
my
=
my
||
{};
// Attributes //
var
job_array_name
=
'
jio/job_array
'
;
var
priv
=
{};
...
...
@@ -10,9 +9,6 @@ var jobManager = (function(spec, my) {
priv
.
interval
=
200
;
priv
.
job_array
=
[];
my
.
jobManager
=
that
;
my
.
jobIdHandler
=
jobIdHandler
;
// Methods //
/**
* Get the job array name in the localStorage
...
...
@@ -140,11 +136,11 @@ var jobManager = (function(spec, my) {
var
i
,
jio_job_array
;
jio_job_array
=
LocalOrCookieStorage
.
getItem
(
'
jio/job_array/
'
+
id
)
||
[];
for
(
i
=
0
;
i
<
jio_job_array
.
length
;
i
+=
1
)
{
var
command_object
=
command
(
jio_job_array
[
i
].
command
,
my
);
var
command_object
=
command
(
jio_job_array
[
i
].
command
);
if
(
command_object
.
canBeRestored
())
{
that
.
addJob
(
job
(
{
storage
:
jio
Namespace
.
storage
(
jio_job_array
[
i
].
storage
,
my
),
command
:
command_object
}
,
my
));
{
storage
:
jio
.
storage
(
jio_job_array
[
i
].
storage
),
command
:
command_object
}));
}
}
};
...
...
OfficeJS/src/jio/jobs/jobRules.js
View file @
dfebe7c8
var
jobRules
=
(
function
(
spec
,
my
)
{
var
jobRules
=
(
function
(
spec
)
{
var
that
=
{};
// Attributes //
var
priv
=
{};
priv
.
compare
=
{};
priv
.
action
=
{};
that
.
eliminate
=
function
()
{
return
'
eliminate
'
;
};
that
.
update
=
function
()
{
return
'
update
'
;
};
that
.
dontAccept
=
function
()
{
return
'
dont accept
'
;
};
that
.
wait
=
function
()
{
return
'
wait
'
;
};
that
.
none
=
function
()
{
return
'
none
'
;
};
Object
.
defineProperty
(
that
,
"
eliminate
"
,{
configurable
:
false
,
enumerable
:
false
,
writable
:
false
,
value
:
function
()
{
return
'
eliminate
'
;
}
});
Object
.
defineProperty
(
that
,
"
update
"
,{
configurable
:
false
,
enumerable
:
false
,
writable
:
false
,
value
:
function
()
{
return
'
update
'
;
}
});
Object
.
defineProperty
(
that
,
"
dontAccept
"
,{
configurable
:
false
,
enumerable
:
false
,
writable
:
false
,
value
:
function
()
{
return
'
dont accept
'
;
}
});
Object
.
defineProperty
(
that
,
"
wait
"
,{
configurable
:
false
,
enumerable
:
false
,
writable
:
false
,
value
:
function
()
{
return
'
wait
'
;
}
});
Object
.
defineProperty
(
that
,
"
none
"
,{
configurable
:
false
,
enumerable
:
false
,
writable
:
false
,
value
:
function
()
{
return
'
none
'
;
}
});
that
.
default_action
=
that
.
none
;
that
.
default_compare
=
function
(
job1
,
job2
)
{
return
(
job1
.
getCommand
().
getDocId
()
===
...
...
@@ -70,12 +85,15 @@ var jobRules = (function(spec, my) {
* @param job2 {object} The new job.
* @return {string} The action string.
*/
that
.
validateJobAccordingToJob
=
function
(
job1
,
job2
)
{
if
(
priv
.
canCompare
(
job1
,
job2
))
{
return
{
action
:
priv
.
getAction
(
job1
,
job2
),
job
:
job1
};
Object
.
defineProperty
(
that
,
"
validateJobAccordingToJob
"
,{
configurable
:
false
,
enumerable
:
false
,
writable
:
false
,
value
:
function
(
job1
,
job2
)
{
if
(
priv
.
canCompare
(
job1
,
job2
))
{
return
{
action
:
priv
.
getAction
(
job1
,
job2
),
job
:
job1
};
}
return
{
action
:
that
.
default_action
(
job1
,
job2
),
job
:
job1
};
}
return
{
action
:
that
.
default_action
(
job1
,
job2
),
job
:
job1
};
};
});
/**
* Adds a rule the action rules.
...
...
@@ -85,12 +103,16 @@ var jobRules = (function(spec, my) {
* @param method2 {string} The action label from the new job.
* @param rule {function} The rule that return an action string.
*/
that
.
addActionRule
=
function
(
method1
,
ongoing
,
method2
,
rule
)
{
var
ongoing_s
=
(
ongoing
?
'
on going
'
:
'
not on going
'
);
priv
.
action
[
method1
]
=
priv
.
action
[
method1
]
||
{};
priv
.
action
[
method1
][
ongoing_s
]
=
priv
.
action
[
method1
][
ongoing_s
]
||
{};
priv
.
action
[
method1
][
ongoing_s
][
method2
]
=
rule
;
};
Object
.
defineProperty
(
that
,
"
addActionRule
"
,{
configurable
:
false
,
enumerable
:
false
,
writable
:
false
,
value
:
function
(
method1
,
ongoing
,
method2
,
rule
)
{
var
ongoing_s
=
(
ongoing
?
'
on going
'
:
'
not on going
'
);
priv
.
action
[
method1
]
=
priv
.
action
[
method1
]
||
{};
priv
.
action
[
method1
][
ongoing_s
]
=
priv
.
action
[
method1
][
ongoing_s
]
||
{};
priv
.
action
[
method1
][
ongoing_s
][
method2
]
=
rule
;
}
});
/**
* Adds a rule the compare rules.
...
...
@@ -100,10 +122,13 @@ var jobRules = (function(spec, my) {
* @param rule {function} The rule that return a boolean
* - true if job1 and job2 can be compared, else false.
*/
that
.
addCompareRule
=
function
(
method1
,
method2
,
rule
)
{
priv
.
compare
[
method1
]
=
priv
.
compare
[
method1
]
||
{};
priv
.
compare
[
method1
][
method2
]
=
rule
;
};
Object
.
defineProperty
(
that
,
"
addCompareRule
"
,{
configurable
:
false
,
enumerable
:
false
,
writable
:
false
,
value
:
function
(
method1
,
method2
,
rule
)
{
priv
.
compare
[
method1
]
=
priv
.
compare
[
method1
]
||
{};
priv
.
compare
[
method1
][
method2
]
=
rule
;
}
});
////////////////////////////////////////////////////////////////////////////
// Adding some rules
...
...
OfficeJS/src/jio/storages/storage.js
View file @
dfebe7c8
...
...
@@ -7,12 +7,12 @@ var storage = function(spec, my) {
priv
.
type
=
spec
.
type
||
''
;
// Methods //
that
.
getType
=
function
()
{
return
priv
.
type
;
};
that
.
setType
=
function
(
type
)
{
priv
.
type
=
type
;
};
Object
.
defineProperty
(
that
,
"
getType
"
,
{
configurable
:
false
,
enumerable
:
false
,
writable
:
false
,
value
:
function
()
{
return
priv
.
type
;
}
}
)
;
/**
* Execute the command on this storage.
...
...
@@ -41,9 +41,10 @@ var storage = function(spec, my) {
that
.
validate
=
function
()
{
var
mess
=
that
.
validateState
();
if
(
mess
)
{
that
.
error
({
status
:
0
,
statusText
:
'
Invalid Storage
'
,
error
:
'
invalid_storage
'
,
message
:
mess
,
reason
:
mess
});
that
.
error
({
status
:
0
,
statusText
:
'
Invalid Storage
'
,
error
:
'
invalid_storage
'
,
message
:
mess
,
reason
:
mess
});
return
false
;
}
return
true
;
...
...
@@ -86,5 +87,31 @@ var storage = function(spec, my) {
that
.
error
=
function
()
{};
that
.
end
=
function
()
{};
// terminate the current job.
priv
.
newCommand
=
function
(
method
,
spec
)
{
var
o
=
spec
||
{};
o
.
label
=
method
;
return
command
(
o
,
my
);
};
that
.
addJob
=
function
(
method
,
storage_spec
,
doc
,
option
,
success
,
error
)
{
var
command_opt
=
{
options
:
option
,
callbacks
:{
success
:
success
,
error
:
error
}
};
if
(
doc
)
{
if
(
method
===
'
get
'
)
{
command_opt
.
docid
=
doc
;
}
else
{
command_opt
.
doc
=
doc
;
}
}
jobManager
.
addJob
(
job
({
storage
:
my
.
storage
(
storage_spec
||
{}),
command
:
priv
.
newCommand
(
method
,
command_opt
)
},
my
)
);
};
return
that
;
};
OfficeJS/src/jio/storages/storageHandler.js
deleted
100644 → 0
View file @
8b66f91e
var
storageHandler
=
function
(
spec
,
my
)
{
spec
=
spec
||
{};
my
=
my
||
{};
var
that
=
storage
(
spec
,
my
),
priv
=
{};
priv
.
newCommand
=
function
(
method
,
spec
)
{
var
o
=
spec
||
{};
o
.
label
=
method
;
return
command
(
o
,
my
);
};
that
.
addJob
=
function
(
method
,
storage_spec
,
doc
,
option
,
success
,
error
)
{
var
command_opt
=
{
options
:
option
,
callbacks
:{
success
:
success
,
error
:
error
}
};
if
(
doc
)
{
if
(
method
===
'
get
'
)
{
command_opt
.
docid
=
doc
;
}
else
{
command_opt
.
doc
=
doc
;
}
}
my
.
jobManager
.
addJob
(
job
({
storage
:
jioNamespace
.
storage
(
storage_spec
||
{}),
command
:
priv
.
newCommand
(
method
,
command_opt
)
},
my
)
);
};
return
that
;
};
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment