Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
jio
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
18
Merge Requests
18
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
jio
Commits
6b952fc2
Commit
6b952fc2
authored
Feb 21, 2018
by
Vincent Bechu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[cloudoostorage] Init cloudoo storage
cloudo storage will be use to convert file from cloudoo server
parent
fc0e7413
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
463 additions
and
1 deletion
+463
-1
Gruntfile.js
Gruntfile.js
+2
-1
src/jio.storage/cloudoostorage.js
src/jio.storage/cloudoostorage.js
+67
-0
test/jio.storage/cloudoostorage.tests.js
test/jio.storage/cloudoostorage.tests.js
+393
-0
test/tests.html
test/tests.html
+1
-0
No files found.
Gruntfile.js
View file @
6b952fc2
...
...
@@ -183,7 +183,8 @@ module.exports = function (grunt) {
'
src/jio.storage/indexeddbstorage.js
'
,
'
src/jio.storage/cryptstorage.js
'
,
'
src/jio.storage/websqlstorage.js
'
,
'
src/jio.storage/fbstorage.js
'
'
src/jio.storage/fbstorage.js
'
,
'
src/jio.storage/cloudoostorage.js
'
],
dest
:
'
dist/<%= pkg.name %>-<%= pkg.version %>.js
'
// dest: 'jio.js'
...
...
src/jio.storage/cloudoostorage.js
0 → 100644
View file @
6b952fc2
/*jslint nomen: true*/
/*global jIO*/
(
function
(
jIO
)
{
"
use strict
"
;
/**
* The jIO CloudooStorage extension
*
* Convert attachment : att_id:format ?!
* cloudoo_info :
* {
* portal_type: "Cloudoo Conversion"
* base_format: format de base ( content_type du document )
* to_convert_list: [liste des format a convertir pendant la synchro]
* format_avaible_list : [liste des formats deja disponible]
* }
*
* @class CloudooStorage
* @constructor
*/
function
CloudooStorage
(
spec
)
{
this
.
_serveur_url
=
spec
.
serveur_url
;
this
.
_sub_storage
=
jIO
.
createJIO
(
spec
.
sub_storage
);
}
CloudooStorage
.
prototype
.
get
=
function
()
{
return
this
.
_sub_storage
.
get
.
apply
(
this
.
_sub_storage
,
arguments
);
};
CloudooStorage
.
prototype
.
post
=
function
()
{
return
this
.
_sub_storage
.
post
.
apply
(
this
.
_sub_storage
,
arguments
);
};
CloudooStorage
.
prototype
.
put
=
function
()
{
return
this
.
_sub_storage
.
put
.
apply
(
this
.
_sub_storage
,
arguments
);
};
CloudooStorage
.
prototype
.
remove
=
function
()
{
return
this
.
_sub_storage
.
remove
.
apply
(
this
.
_sub_storage
,
arguments
);
};
CloudooStorage
.
prototype
.
getAttachment
=
function
()
{
return
this
.
_sub_storage
.
getAttachment
.
apply
(
this
.
_sub_storage
,
arguments
);
};
CloudooStorage
.
prototype
.
putAttachment
=
function
()
{
// putAttachment sur l'id de base suprime les conversions existente
// Les refaire sur la synchro ?
//
return
this
.
_sub_storage
.
putAttachment
.
apply
(
this
.
_sub_storage
,
arguments
);
};
CloudooStorage
.
prototype
.
removeAttachment
=
function
()
{
return
this
.
_sub_storage
.
removeAttachment
.
apply
(
this
.
_sub_storage
,
arguments
);
};
CloudooStorage
.
prototype
.
allAttachments
=
function
()
{
return
this
.
_sub_storage
.
allAttachments
.
apply
(
this
.
_sub_storage
,
arguments
);
};
CloudooStorage
.
prototype
.
repair
=
function
()
{
return
this
.
_sub_storage
.
repair
.
apply
(
this
.
_sub_storage
,
arguments
);
};
CloudooStorage
.
prototype
.
hasCapacity
=
function
(
name
)
{
return
this
.
_sub_storage
.
hasCapacity
(
name
);
};
CloudooStorage
.
prototype
.
buildQuery
=
function
()
{
return
this
.
_sub_storage
.
buildQuery
.
apply
(
this
.
_sub_storage
,
arguments
);
};
jIO
.
addStorage
(
'
cloudoo
'
,
CloudooStorage
);
}(
jIO
));
test/jio.storage/cloudoostorage.tests.js
0 → 100644
View file @
6b952fc2
/*jslint nomen: true*/
/*global jIO, Blob*/
(
function
(
jIO
,
Blob
)
{
"
use strict
"
;
var
test
=
QUnit
.
test
,
stop
=
QUnit
.
stop
,
start
=
QUnit
.
start
,
ok
=
QUnit
.
ok
,
expect
=
QUnit
.
expect
,
deepEqual
=
QUnit
.
deepEqual
,
equal
=
QUnit
.
equal
,
throws
=
QUnit
.
throws
,
module
=
QUnit
.
module
,
cloudoo_url
=
'
https://softinst77579.host.vifib.net/
'
;
/////////////////////////////////////////////////////////////////
// Custom test substorage definition
/////////////////////////////////////////////////////////////////
function
Storage200
()
{
return
this
;
}
jIO
.
addStorage
(
'
cloudoostorage200
'
,
Storage200
);
/////////////////////////////////////////////////////////////////
// CryptStorage.constructor
/////////////////////////////////////////////////////////////////
module
(
"
cloudooStorage.constructor
"
);
test
(
"
create substorage
"
,
function
()
{
var
jio
=
jIO
.
createJIO
({
type
:
"
cloudoo
"
,
url
:
cloudoo_url
,
sub_storage
:
{
type
:
"
cloudoostorage200
"
}
});
equal
(
jio
.
__type
,
"
cloudoo
"
);
equal
(
jio
.
__storage
.
_url
,
cloudoo_url
);
equal
(
jio
.
__storage
.
_sub_storage
.
__type
,
"
cloudoostorage200
"
);
});
/////////////////////////////////////////////////////////////////
// CryptStorage.get
/////////////////////////////////////////////////////////////////
module
(
"
cloudooStorage.get
"
);
test
(
"
get called substorage get
"
,
function
()
{
stop
();
expect
(
2
);
var
jio
=
jIO
.
createJIO
({
type
:
"
cloudoo
"
,
url
:
cloudoo_url
,
sub_storage
:
{
type
:
"
cloudoostorage200
"
}
});
Storage200
.
prototype
.
get
=
function
(
param
)
{
equal
(
param
,
"
bar
"
,
"
get 200 called
"
);
return
{
title
:
"
foo
"
};
};
jio
.
get
(
"
bar
"
)
.
then
(
function
(
result
)
{
deepEqual
(
result
,
{
"
title
"
:
"
foo
"
},
"
Check document
"
);
})
.
fail
(
function
(
error
)
{
ok
(
false
,
error
);
})
.
always
(
function
()
{
start
();
});
});
/////////////////////////////////////////////////////////////////
// CryptStorage.post
/////////////////////////////////////////////////////////////////
module
(
"
cloudooStorage.post
"
);
test
(
"
post called substorage post
"
,
function
()
{
stop
();
expect
(
2
);
var
jio
=
jIO
.
createJIO
({
type
:
"
cloudoo
"
,
url
:
cloudoo_url
,
sub_storage
:
{
type
:
"
cloudoostorage200
"
}
});
Storage200
.
prototype
.
post
=
function
(
param
)
{
deepEqual
(
param
,
{
"
title
"
:
"
foo
"
},
"
post 200 called
"
);
return
"
youhou
"
;
};
jio
.
post
({
"
title
"
:
"
foo
"
})
.
then
(
function
(
result
)
{
equal
(
result
,
"
youhou
"
);
})
.
fail
(
function
(
error
)
{
ok
(
false
,
error
);
})
.
always
(
function
()
{
start
();
});
});
/////////////////////////////////////////////////////////////////
// CryptStorage.put
/////////////////////////////////////////////////////////////////
module
(
"
cloudooStorage.put
"
);
test
(
"
put called substorage put
"
,
function
()
{
stop
();
expect
(
3
);
var
jio
=
jIO
.
createJIO
({
type
:
"
cloudoo
"
,
url
:
cloudoo_url
,
sub_storage
:
{
type
:
"
cloudoostorage200
"
}
});
Storage200
.
prototype
.
put
=
function
(
id
,
param
)
{
equal
(
id
,
"
bar
"
,
"
put 200 called
"
);
deepEqual
(
param
,
{
"
title
"
:
"
foo
"
},
"
put 200 called
"
);
return
id
;
};
jio
.
put
(
"
bar
"
,
{
"
title
"
:
"
foo
"
})
.
then
(
function
(
result
)
{
equal
(
result
,
"
bar
"
);
})
.
fail
(
function
(
error
)
{
ok
(
false
,
error
);
})
.
always
(
function
()
{
start
();
});
});
/////////////////////////////////////////////////////////////////
// CryptStorage.remove
/////////////////////////////////////////////////////////////////
module
(
"
cloudooStorage.remove
"
);
test
(
"
remove called substorage remove
"
,
function
()
{
stop
();
expect
(
2
);
var
jio
=
jIO
.
createJIO
({
type
:
"
cloudoo
"
,
url
:
cloudoo_url
,
sub_storage
:
{
type
:
"
cloudoostorage200
"
}
});
Storage200
.
prototype
.
remove
=
function
(
id
)
{
deepEqual
(
id
,
"
bar
"
,
"
remove 200 called
"
);
return
id
;
};
jio
.
remove
(
"
bar
"
)
.
then
(
function
(
result
)
{
equal
(
result
,
"
bar
"
);
})
.
fail
(
function
(
error
)
{
ok
(
false
,
error
);
})
.
always
(
function
()
{
start
();
});
});
/////////////////////////////////////////////////////////////////
// CryptStorage.hasCapacity
/////////////////////////////////////////////////////////////////
module
(
"
cloudooStorage.hasCapacity
"
);
test
(
"
hasCapacity return substorage value
"
,
function
()
{
var
jio
=
jIO
.
createJIO
({
type
:
"
cloudoo
"
,
url
:
cloudoo_url
,
sub_storage
:
{
type
:
"
cloudoostorage200
"
}
});
delete
Storage200
.
prototype
.
hasCapacity
;
throws
(
function
()
{
jio
.
hasCapacity
(
"
foo
"
);
},
function
(
error
)
{
ok
(
error
instanceof
jIO
.
util
.
jIOError
);
equal
(
error
.
status_code
,
501
);
equal
(
error
.
message
,
"
Capacity 'foo' is not implemented on 'uuidstorage200'
"
);
return
true
;
}
);
});
/////////////////////////////////////////////////////////////////
// CryptStorage.buildQuery
/////////////////////////////////////////////////////////////////
module
(
"
cloudooStorage.buildQuery
"
);
test
(
"
buildQuery return substorage buildQuery
"
,
function
()
{
stop
();
expect
(
2
);
var
jio
=
jIO
.
createJIO
({
type
:
"
cloudoo
"
,
url
:
cloudoo_url
,
sub_storage
:
{
type
:
"
cloudoostorage200
"
}
});
Storage200
.
prototype
.
hasCapacity
=
function
()
{
return
true
;
};
Storage200
.
prototype
.
buildQuery
=
function
(
options
)
{
deepEqual
(
options
,
{
include_docs
:
false
,
sort_on
:
[[
"
title
"
,
"
ascending
"
]],
limit
:
[
5
],
select_list
:
[
"
title
"
,
"
id
"
],
uuid
:
'
title: "two"
'
},
"
allDocs parameter
"
);
return
"
bar
"
;
};
jio
.
allDocs
({
include_docs
:
false
,
sort_on
:
[[
"
title
"
,
"
ascending
"
]],
limit
:
[
5
],
select_list
:
[
"
title
"
,
"
id
"
],
uuid
:
'
title: "two"
'
})
.
then
(
function
(
result
)
{
deepEqual
(
result
,
{
data
:
{
rows
:
"
bar
"
,
total_rows
:
3
}
});
})
.
fail
(
function
(
error
)
{
ok
(
false
,
error
);
})
.
always
(
function
()
{
start
();
});
});
/////////////////////////////////////////////////////////////////
// CryptStorage.removeAttachment
/////////////////////////////////////////////////////////////////
module
(
"
cloudooStorage.removeAttachment
"
);
test
(
"
removeAttachment called substorage removeAttachment
"
,
function
()
{
stop
();
expect
(
3
);
var
jio
=
jIO
.
createJIO
({
type
:
"
cloudoo
"
,
url
:
cloudoo_url
,
sub_storage
:
{
type
:
"
cloudoostorage200
"
}
});
Storage200
.
prototype
.
removeAttachment
=
function
(
id
,
name
)
{
equal
(
id
,
"
bar
"
,
"
removeAttachment 200 called
"
);
equal
(
name
,
"
foo
"
,
"
removeAttachment 200 called
"
);
return
"
Removed
"
;
};
jio
.
removeAttachment
(
"
bar
"
,
"
foo
"
)
.
then
(
function
(
result
)
{
equal
(
result
,
"
Removed
"
);
})
.
fail
(
function
(
error
)
{
ok
(
false
,
error
);
})
.
always
(
function
()
{
start
();
});
});
/////////////////////////////////////////////////////////////////
// CryptStorage.allAttachments
/////////////////////////////////////////////////////////////////
module
(
"
cloudooStorage.allAttachments
"
);
test
(
"
allAttachments called substorage allAttachments
"
,
function
()
{
stop
();
expect
(
2
);
var
jio
=
jIO
.
createJIO
({
type
:
"
cloudoo
"
,
url
:
cloudoo_url
,
sub_storage
:
{
type
:
"
cloudoostorage200
"
}
});
Storage200
.
prototype
.
allAttachments
=
function
(
id
)
{
equal
(
id
,
"
bar
"
,
"
allAttachments, 200 called
"
);
return
{
attachmentname
:
{}};
};
jio
.
allAttachments
(
"
bar
"
)
.
then
(
function
(
result
)
{
deepEqual
(
result
,
{
attachmentname
:
{}
},
"
Check document
"
);
})
.
fail
(
function
(
error
)
{
ok
(
false
,
error
);
})
.
always
(
function
()
{
start
();
});
});
/////////////////////////////////////////////////////////////////
// CryptStorage.getAttachment
/////////////////////////////////////////////////////////////////
module
(
"
cloudooStorage.getAttachment
"
);
test
(
"
getAttachment called substorage getAttachment
"
,
function
()
{
stop
();
expect
(
3
);
var
jio
=
jIO
.
createJIO
({
type
:
"
cloudoo
"
,
url
:
cloudoo_url
,
sub_storage
:
{
type
:
"
cloudoostorage200
"
}
}),
blob
=
new
Blob
([
""
]);
Storage200
.
prototype
.
getAttachment
=
function
(
id
,
name
)
{
equal
(
id
,
"
bar
"
,
"
getAttachment 200 called
"
);
equal
(
name
,
"
foo
"
,
"
getAttachment 200 called
"
);
return
blob
;
};
jio
.
getAttachment
(
"
bar
"
,
"
foo
"
)
.
then
(
function
(
result
)
{
equal
(
result
,
blob
);
})
.
fail
(
function
(
error
)
{
ok
(
false
,
error
);
})
.
always
(
function
()
{
start
();
});
});
/////////////////////////////////////////////////////////////////
// CryptStorage.putAttachment
/////////////////////////////////////////////////////////////////
module
(
"
cloudooStorage.putAttachment
"
);
test
(
"
putAttachment called substorage putAttachment
"
,
function
()
{
stop
();
expect
(
4
);
var
jio
=
jIO
.
createJIO
({
type
:
"
cloudoo
"
,
url
:
cloudoo_url
,
sub_storage
:
{
type
:
"
cloudoostorage200
"
}
}),
blob
=
new
Blob
([
""
]);
Storage200
.
prototype
.
putAttachment
=
function
(
id
,
name
,
blob2
)
{
equal
(
id
,
"
bar
"
,
"
putAttachment 200 called
"
);
equal
(
name
,
"
foo
"
,
"
putAttachment 200 called
"
);
deepEqual
(
blob2
,
blob
,
"
putAttachment 200 called
"
);
return
"
OK
"
;
};
jio
.
putAttachment
(
"
bar
"
,
"
foo
"
,
blob
)
.
then
(
function
(
result
)
{
equal
(
result
,
"
OK
"
);
})
.
fail
(
function
(
error
)
{
ok
(
false
,
error
);
})
.
always
(
function
()
{
start
();
});
});
}(
jIO
,
Blob
));
test/tests.html
View file @
6b952fc2
...
...
@@ -50,6 +50,7 @@
<!--script src="jio.storage/qiniustorage.tests.js"></script-->
<!--script src="jio.storage/indexstorage.tests.js"></script-->
<script
src=
"jio.storage/cryptstorage.tests.js"
></script>
<script
src=
"jio.storage/cloudoostorage.tests.js"
></script>
<script
src=
"jio.storage/dropboxstorage.tests.js"
></script>
<script
src=
"jio.storage/zipstorage.tests.js"
></script>
<script
src=
"jio.storage/gdrivestorage.tests.js"
></script>
...
...
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