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
81600fca
Commit
81600fca
authored
Feb 27, 2018
by
Vincent Bechu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[cloudoostorage] convert with getAttachment
parent
0c6ae8dc
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
124 additions
and
34 deletions
+124
-34
src/jio.storage/cloudoostorage.js
src/jio.storage/cloudoostorage.js
+7
-4
test/jio.storage/cloudoostorage.tests.js
test/jio.storage/cloudoostorage.tests.js
+117
-30
No files found.
src/jio.storage/cloudoostorage.js
View file @
81600fca
...
...
@@ -61,7 +61,7 @@
})
.
push
(
function
(
result
)
{
var
data
=
(
new
DOMParser
().
parseFromString
(
result
.
currentTarget
.
response
,
result
.
target
.
responseText
,
"
application/xml
"
)),
content
=
data
.
getElementsByTagName
(
'
string
'
)[
0
].
textContent
;
...
...
@@ -105,7 +105,7 @@
return
convert
(
storage
,
blob
,
info_doc
.
format
,
format
);
})
.
push
(
function
(
blob
)
{
return
storage
.
putAttachment
(
id
,
attachment_id
+
'
?
'
+
format
)
return
storage
.
putAttachment
(
id
,
attachment_id
+
'
?
'
+
format
,
blob
)
.
push
(
function
()
{
info_doc
.
convert_dict
[
format
]
=
true
;
return
storage
.
put
(
...
...
@@ -147,7 +147,7 @@
return
RSVP
.
all
(
promise_list
);
})
.
push
(
function
()
{
doc_info
.
convert_
lis
t
=
{};
doc_info
.
convert_
dic
t
=
{};
return
doc_info
;
});
}
...
...
@@ -205,12 +205,15 @@
CloudooStorage
.
prototype
.
putAttachment
=
function
(
id
,
attachment_id
)
{
var
storage
=
this
;
return
this
.
_sub_storage
.
putAttachment
.
apply
(
this
.
_sub_storage
,
arguments
)
.
push
(
function
()
{
.
push
(
function
(
result
)
{
var
att_id_list
=
attachment_id
.
split
(
'
?
'
);
if
(
att_id_list
.
length
===
1
)
{
return
removeConvertedAttachment
(
storage
,
id
,
attachment_id
)
.
push
(
function
(
doc_info
)
{
return
storage
.
put
(
getInfoDocId
(
id
,
attachment_id
),
doc_info
);
})
.
push
(
function
()
{
return
result
;
});
}
});
...
...
test/jio.storage/cloudoostorage.tests.js
View file @
81600fca
/*jslint nomen: true*/
/*global jIO, Blob*/
(
function
(
jIO
,
Blob
)
{
/*global jIO, Blob
, sinon
*/
(
function
(
jIO
,
Blob
,
sinon
)
{
"
use strict
"
;
var
test
=
QUnit
.
test
,
stop
=
QUnit
.
stop
,
...
...
@@ -11,7 +11,7 @@
equal
=
QUnit
.
equal
,
throws
=
QUnit
.
throws
,
module
=
QUnit
.
module
,
cloudoo_url
=
'
https://
softinst77579.host.vifib.net
/
'
;
cloudoo_url
=
'
https://
www.cloudooo.com
/
'
;
/////////////////////////////////////////////////////////////////
// Custom test substorage definition
...
...
@@ -258,7 +258,7 @@
module
(
"
cloudooStorage.removeAttachment
"
);
test
(
"
removeAttachment called substorage removeAttachment
"
,
function
()
{
stop
();
expect
(
3
);
expect
(
4
);
var
jio
=
jIO
.
createJIO
({
type
:
"
cloudoo
"
,
...
...
@@ -268,6 +268,19 @@
}
});
Storage200
.
prototype
.
get
=
function
(
id
)
{
if
(
id
!==
"
bar
"
)
{
throw
new
jIO
.
util
.
jIOError
(
'
not found
'
,
404
);
}
return
{};
};
Storage200
.
prototype
.
remove
=
function
(
id
)
{
equal
(
id
,
'
cloudoo/bar/foo
'
,
"
remove 200 called
"
);
return
id
;
};
Storage200
.
prototype
.
removeAttachment
=
function
(
id
,
name
)
{
equal
(
id
,
"
bar
"
,
"
removeAttachment 200 called
"
);
equal
(
name
,
"
foo
"
,
"
removeAttachment 200 called
"
);
...
...
@@ -276,7 +289,7 @@
jio
.
removeAttachment
(
"
bar
"
,
"
foo
"
)
.
then
(
function
(
result
)
{
equal
(
result
,
"
Removed
"
);
equal
(
result
,
"
cloudoo/bar/foo
"
);
})
.
fail
(
function
(
error
)
{
ok
(
false
,
error
);
...
...
@@ -322,19 +335,31 @@
/////////////////////////////////////////////////////////////////
// CryptStorage.getAttachment
/////////////////////////////////////////////////////////////////
module
(
"
cloudooStorage.getAttachment
"
);
module
(
"
cloudooStorage.getAttachment
"
,
{
setup
:
function
()
{
this
.
server
=
sinon
.
fakeServer
.
create
();
this
.
server
.
autoRespond
=
true
;
this
.
server
.
autoRespondAfter
=
5
;
this
.
jio
=
jIO
.
createJIO
({
type
:
"
cloudoo
"
,
url
:
cloudoo_url
,
sub_storage
:
{
type
:
"
cloudoostorage200
"
}
});
},
teardown
:
function
()
{
this
.
server
.
restore
();
delete
this
.
server
;
}
});
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
([
""
]);
var
blob
=
new
Blob
([
""
]);
Storage200
.
prototype
.
getAttachment
=
function
(
id
,
name
)
{
equal
(
id
,
"
bar
"
,
"
getAttachment 200 called
"
);
...
...
@@ -342,7 +367,7 @@
return
blob
;
};
jio
.
getAttachment
(
"
bar
"
,
"
foo
"
)
this
.
jio
.
getAttachment
(
"
bar
"
,
"
foo
"
)
.
then
(
function
(
result
)
{
equal
(
result
,
blob
);
})
...
...
@@ -354,28 +379,71 @@
});
});
test
(
"
getAttachment c
alled substorage getAttachment
"
,
function
()
{
test
(
"
getAttachment c
onvert from docy to docx
"
,
function
()
{
stop
();
expect
(
3
);
expect
(
10
);
var
jio
=
jIO
.
createJIO
({
type
:
"
cloudoo
"
,
url
:
cloudoo_url
,
sub_storage
:
{
type
:
"
cloudoostorage200
"
}
}
),
blob
=
new
Blob
([
""
]);
var
blob
=
new
Blob
([
"
documentauformatdocy
"
]),
server
=
this
.
server
,
blob_convert
=
new
Blob
([
"
documentauformatdocx
"
],
{
type
:
"
docx
"
});
this
.
server
.
respondWith
(
"
POST
"
,
cloudoo_url
,
[
200
,
{
"
Content-Type
"
:
"
text/xml
"
}
,
'
<?xml version="1.0" encoding="UTF-8"?>
'
+
'
<string>ZG9jdW1lbnRhdWZvcm1hdGRvY3g=</string>
'
]);
Storage200
.
prototype
.
getAttachment
=
function
(
id
,
name
)
{
equal
(
id
,
"
bar
"
,
"
getAttachment 200 called
"
);
equal
(
name
,
"
foo
"
,
"
getAttachment 200 called
"
);
if
(
name
===
"
data?docx
"
)
{
throw
new
jIO
.
util
.
jIOError
(
"
can't find
"
,
404
);
}
return
blob
;
};
jio
.
getAttachment
(
"
bar
"
,
"
foo
"
)
Storage200
.
prototype
.
putAttachment
=
function
(
id
,
att_id
,
blob
)
{
equal
(
id
,
"
bar
"
,
"
putAttachment 200 called
"
);
equal
(
att_id
,
"
data?docx
"
,
"
putAttachment 200 called
"
);
deepEqual
(
blob
,
blob_convert
,
"
putAttachment 200 called
"
);
};
Storage200
.
prototype
.
get
=
function
(
id
)
{
if
(
id
===
"
cloudoo/bar/data
"
)
{
throw
new
jIO
.
util
.
jIOError
(
"
can't find
"
,
404
);
}
if
(
id
===
"
bar
"
)
{
return
{
content_type
:
"
application/x-asc-text
"
};
}
equal
(
id
,
""
,
"
get 200 called
"
);
return
{};
};
Storage200
.
prototype
.
put
=
function
(
id
,
doc
)
{
equal
(
id
,
"
cloudoo/bar/data
"
,
"
put 200 called
"
);
deepEqual
(
doc
,
{
"
attachment_id
"
:
"
data
"
,
"
convert_dict
"
:
{
"
docx
"
:
true
},
"
doc_id
"
:
"
bar
"
,
"
format
"
:
"
docy
"
,
"
portal_type
"
:
"
Conversion Info
"
},
"
put doc 200 called
"
);
return
id
;
};
this
.
jio
.
getAttachment
(
"
bar
"
,
"
data?docx
"
)
.
then
(
function
(
result
)
{
equal
(
result
,
blob
);
equal
(
server
.
requests
.
length
,
1
);
equal
(
server
.
requests
[
0
].
requestBody
,
'
<?xml version="1.0" encoding="UTF-8"?><methodCall>
'
+
'
<methodName>convertFile</methodName><params><param><value>
'
+
'
<string>ZG9jdW1lbnRhdWZvcm1hdGRvY3k=</string></value></param>
'
+
'
<param><value><string>docy</string></value></param>
'
+
'
<param><value><string>docx
'
+
'
</string></value></param></params></methodCall>
'
);
deepEqual
(
result
,
blob_convert
,
"
check result
"
);
})
.
fail
(
function
(
error
)
{
ok
(
false
,
error
);
...
...
@@ -390,7 +458,7 @@
module
(
"
cloudooStorage.putAttachment
"
);
test
(
"
putAttachment called substorage putAttachment
"
,
function
()
{
stop
();
expect
(
4
);
expect
(
6
);
var
jio
=
jIO
.
createJIO
({
type
:
"
cloudoo
"
,
...
...
@@ -401,6 +469,13 @@
}),
blob
=
new
Blob
([
""
]);
Storage200
.
prototype
.
get
=
function
(
id
)
{
if
(
id
!==
'
bar
'
)
{
throw
new
jIO
.
util
.
jIOError
(
"
can't find
"
,
404
);
}
return
{};
};
Storage200
.
prototype
.
putAttachment
=
function
(
id
,
name
,
blob2
)
{
equal
(
id
,
"
bar
"
,
"
putAttachment 200 called
"
);
equal
(
name
,
"
foo
"
,
"
putAttachment 200 called
"
);
...
...
@@ -409,6 +484,18 @@
return
"
OK
"
;
};
Storage200
.
prototype
.
put
=
function
(
id
,
doc
)
{
equal
(
id
,
"
cloudoo/bar/foo
"
,
"
put id 200 called
"
);
deepEqual
(
doc
,
{
"
attachment_id
"
:
"
foo
"
,
"
convert_dict
"
:
{},
"
doc_id
"
:
"
bar
"
,
"
format
"
:
undefined
,
"
portal_type
"
:
"
Conversion Info
"
},
"
put doc 200 called
"
);
return
id
;
};
jio
.
putAttachment
(
"
bar
"
,
"
foo
"
,
blob
)
.
then
(
function
(
result
)
{
equal
(
result
,
"
OK
"
);
...
...
@@ -421,4 +508,4 @@
});
});
}(
jIO
,
Blob
));
}(
jIO
,
Blob
,
sinon
));
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