Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
jio-main
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Hardik Juneja
jio-main
Commits
e45edf9f
Commit
e45edf9f
authored
Jan 10, 2013
by
Sven Franck
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
jslint pass replicatestorage.js
parent
a8f62949
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
97 additions
and
91 deletions
+97
-91
src/jio.storage/replicatestorage.js
src/jio.storage/replicatestorage.js
+97
-91
No files found.
src/jio.storage/replicatestorage.js
View file @
e45edf9f
/*jslint indent: 2, maxlen: 80, sloppy: true, nomen: true */
/*global jIO: true */
jIO
.
addStorageType
(
'
replicate
'
,
function
(
spec
,
my
)
{
var
that
,
cloned_option
,
priv
=
{},
super_serialized
=
that
.
serialized
;
spec
=
spec
||
{};
var
that
=
my
.
basicStorage
(
spec
,
my
),
priv
=
{}
;
that
=
my
.
basicStorage
(
spec
,
my
)
;
priv
.
return_value_array
=
[];
priv
.
storagelist
=
spec
.
storagelist
||
[];
priv
.
nb_storage
=
priv
.
storagelist
.
length
;
var
super_serialized
=
that
.
serialized
;
that
.
serialized
=
function
()
{
var
o
=
super_serialized
();
o
.
storagelist
=
priv
.
storagelist
;
...
...
@@ -15,7 +20,7 @@ jIO.addStorageType('replicate', function (spec, my) {
that
.
validateState
=
function
()
{
if
(
priv
.
storagelist
.
length
===
0
)
{
return
'
Need at least one parameter: "storagelist"
'
+
return
'
Need at least one parameter: "storagelist"
'
+
'
containing at least one storage.
'
;
}
return
''
;
...
...
@@ -25,21 +30,22 @@ jIO.addStorageType('replicate', function (spec, my) {
return
(
error_array
.
length
===
priv
.
nb_storage
);
};
priv
.
doJob
=
function
(
command
,
errormessage
,
nodocid
)
{
var
done
=
false
,
error_array
=
[],
i
,
priv
.
doJob
=
function
(
command
,
errormessage
,
nodocid
)
{
var
done
=
false
,
error_array
=
[],
i
,
error
=
function
(
err
)
{
if
(
!
done
)
{
error_array
.
push
(
err
);
if
(
priv
.
isTheLast
(
error_array
))
{
that
.
error
({
status
:
207
,
statusText
:
'
Multi-Status
'
,
error
:
'
multi_status
'
,
message
:
'
All
'
+
errormessage
+
(
!
nodocid
?
'
"
'
+
command
.
getDocId
()
+
'
"
'
:
'
'
)
+
'
requests have failed.
'
,
reason
:
'
requests fail
'
,
array
:
error_array
that
.
error
({
status
:
207
,
statusText
:
'
Multi-Status
'
,
error
:
'
multi_status
'
,
message
:
'
All
'
+
errormessage
+
(
!
nodocid
?
'
"
'
+
command
.
getDocId
()
+
'
"
'
:
'
'
)
+
'
requests have failed.
'
,
reason
:
'
requests fail
'
,
array
:
error_array
});
}
}
...
...
@@ -47,18 +53,18 @@ jIO.addStorageType('replicate', function (spec, my) {
success
=
function
(
val
)
{
if
(
!
done
)
{
done
=
true
;
that
.
success
(
val
);
that
.
success
(
val
);
}
};
for
(
i
=
0
;
i
<
priv
.
nb_storage
;
i
+=
1
)
{
var
cloned_option
=
command
.
cloneOption
();
that
.
addJob
(
command
.
getLabel
(),
priv
.
storagelist
[
i
],
command
.
cloneDoc
(),
cloned_option
,
success
,
error
);
for
(
i
=
0
;
i
<
priv
.
nb_storage
;
i
+=
1
)
{
cloned_option
=
command
.
cloneOption
();
that
.
addJob
(
command
.
getLabel
(),
priv
.
storagelist
[
i
],
command
.
cloneDoc
(),
cloned_option
,
success
,
error
);
}
};
that
.
post
=
function
(
command
)
{
priv
.
doJob
(
command
,
'
post
'
);
priv
.
doJob
(
command
,
'
post
'
);
that
.
end
();
};
...
...
@@ -67,7 +73,7 @@ jIO.addStorageType('replicate', function (spec, my) {
* @method put
*/
that
.
put
=
function
(
command
)
{
priv
.
doJob
(
command
,
'
put
'
);
priv
.
doJob
(
command
,
'
put
'
);
that
.
end
();
};
...
...
@@ -77,7 +83,7 @@ jIO.addStorageType('replicate', function (spec, my) {
* @method get
*/
that
.
get
=
function
(
command
)
{
priv
.
doJob
(
command
,
'
get
'
);
priv
.
doJob
(
command
,
'
get
'
);
that
.
end
();
};
...
...
@@ -87,7 +93,7 @@ jIO.addStorageType('replicate', function (spec, my) {
* @method allDocs
*/
that
.
allDocs
=
function
(
command
)
{
priv
.
doJob
(
command
,
'
allDocs
'
,
true
);
priv
.
doJob
(
command
,
'
allDocs
'
,
true
);
that
.
end
();
};
...
...
@@ -96,9 +102,9 @@ jIO.addStorageType('replicate', function (spec, my) {
* @method remove
*/
that
.
remove
=
function
(
command
)
{
priv
.
doJob
(
command
,
'
remove
'
);
priv
.
doJob
(
command
,
'
remove
'
);
that
.
end
();
};
return
that
;
};
}
)
;
\ No newline at end of file
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