Commit 9b6bc977 authored by Jonathan Rivalan's avatar Jonathan Rivalan

-added the splitstorage.js \n -adapted the tests from the split + localstorage...

-added the splitstorage.js \n -adapted the tests from the split + localstorage to split + S3 Storage
parent 6ca256a3
...@@ -848,7 +848,8 @@ ...@@ -848,7 +848,8 @@
function putDocument() { function putDocument() {
var data, doc; var data, doc;
data = JSON.parse(my_document); //data = JSON.parse(my_document);
data = my_document;
doc = priv.updateMeta(data, docId, attachId, "remove", ''); doc = priv.updateMeta(data, docId, attachId, "remove", '');
that.XHRwrapper(command, docId, '', 'PUT', mime, doc, that.XHRwrapper(command, docId, '', 'PUT', mime, doc,
false, false, function (reponse) { false, false, function (reponse) {
...@@ -860,8 +861,23 @@ ...@@ -860,8 +861,23 @@
function getDocument() { function getDocument() {
that.XHRwrapper(command, docId, '', 'GET', mime, '', false, false, that.XHRwrapper(command, docId, '', 'GET', mime, '', false, false,
function (response) { function (response) {
my_document = response; if (response == '404'){
if (JSON.parse(my_document)._attachments[attachId] !== undefined){ return command.error(
404,
"missing document",
"This Document does not exist"
);
} else {
my_document = JSON.parse(response);
if (my_document._attachments == undefined){
return command.error(
404,
"missing attachment",
"This Document has no attachments"
);
}
else {
if (my_document._attachments[attachId] !== undefined){
putDocument(); putDocument();
} else { } else {
return command.error( return command.error(
...@@ -871,6 +887,8 @@ ...@@ -871,6 +887,8 @@
); );
} }
} }
}
}
); );
} }
getDocument(); getDocument();
...@@ -882,7 +900,7 @@ ...@@ -882,7 +900,7 @@
* @param {object} command The JIO command * @param {object} command The JIO command
**/ **/
that.allDocs = function (command) { that.allDocs = function (command, param, options) {
var my_document, mime; var my_document, mime;
my_document = null; my_document = null;
mime = 'text/plain; charset=UTF-8'; mime = 'text/plain; charset=UTF-8';
...@@ -946,11 +964,6 @@ ...@@ -946,11 +964,6 @@
errCallback = function (err) { errCallback = function (err) {
if (err.status === 404) { if (err.status === 404) {
//status
//statustext "Not Found"
//error
//reason "reason"
//message "did not work"
err.error = "not_found"; err.error = "not_found";
command.error(err); command.error(err);
} else { } else {
...@@ -960,81 +973,60 @@ ...@@ -960,81 +973,60 @@
i = resultTable.length - 1; i = resultTable.length - 1;
///* JONR : what is the replacement for command.getOption ? */
// if (command.getOption("include_docs") === true) { // if (command.getOption("include_docs") === true) {
///*TRISTANC :
// for (i; i >= 0; i -= 1) { //allDocs = function (command, param, options) {
// keyId = resultTable[i]; //if (options.include_docs) {
// Signature = that.encodeAuthorization(keyId); if (options.include_docs) {
// callURL = 'http://' + priv.server + '.s3.amazonaws.com/' + keyId;
// requestUTC = new Date().toUTCString();
// parse = true;
// allDocResponse.rows[i] = {
// "id": priv.fileNameToIds(keyId).join(),
// "key": keyId,
// "value": {}
// };
// checkCounter = i;
// $.ajax({
// contentType : '',
// crossdomain : true,
// url : callURL,
// type : 'GET',
// headers : {
// 'Authorization' : "AWS"
// + " "
// + priv.AWSIdentifier
// + ":"
// + Signature,
// 'x-amz-date' : requestUTC,
// 'Content-Type' : 'application/json'
// //'Content-MD5' : ''
// //'Content-Length' : ,
// //'Expect' : ,
// //'x-amz-security-token' : ,
// },
// success : dealCallback(i, countB, allDocResponse),
// error : errCallback(command.error)
// });
// countB += 1;
// }
// }
//else {
for (i; i >= 0; i -= 1) { for (i; i >= 0; i -= 1) {
keyId = resultTable[i]; keyId = resultTable[i];
Signature = that.encodeAuthorization(keyId);
callURL = 'http://' + priv.server + '.s3.amazonaws.com/' + keyId;
requestUTC = new Date().toUTCString();
parse = true;
allDocResponse.rows[i] = { allDocResponse.rows[i] = {
"id": priv.fileNameToIds(keyId).join(), "id": priv.fileNameToIds(keyId).join(),
"key": keyId,
"value": {}
};
checkCounter = i;
$.ajax({
contentType : '',
crossdomain : true,
url : callURL,
type : 'GET',
headers : {
'Authorization' : "AWS"
+ " "
+ priv.AWSIdentifier
+ ":"
+ Signature,
'x-amz-date' : requestUTC,
'Content-Type' : 'application/json'
//'Content-MD5' : ''
//'Content-Length' : ,
//'Expect' : ,
//'x-amz-security-token' : ,
},
success : dealCallback(i, countB, allDocResponse),
error : errCallback(command.error)
});
countB += 1;
}
}
else {
for (i; i >= 0; i -= 1) {
keyId = resultTable[i];
allDocResponse.rows[i] = {
"id": priv.fileNameToIds(keyId).join(),
"key": priv.fileNameToIds(keyId).join(),
"value": {} "value": {}
}; };
} }
// allDocResponse = {
// "data": {
// "total_rows": 2,
// "rows": [{
// "id": "lol",
// "value": {}
// }, {
// "id": "b",
// "value": {}
// }]
// },
// "method": "allDocs",
// "result": "success",
// "status": 200,
// "statusText": "Ok"
// };
allDocResponse = {"data":allDocResponse}; allDocResponse = {"data":allDocResponse};
command.success(allDocResponse); command.success(allDocResponse);
}
//}
} }
function getXML() { function getXML() {
......
This diff is collapsed.
This diff is collapsed.
...@@ -98,6 +98,8 @@ JobQueue.prototype.repair = function () { ...@@ -98,6 +98,8 @@ JobQueue.prototype.repair = function () {
* @return {Number} The generated id * @return {Number} The generated id
*/ */
JobQueue.prototype.post = function (job) { JobQueue.prototype.post = function (job) {
console.log('jio core');
console.log(job);
var i, next = 1; var i, next = 1;
// get next id // get next id
for (i = 0; i < this._array.length; i += 1) { for (i = 0; i < this._array.length; i += 1) {
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
<script src="../../complex_queries.js"></script> <script src="../../complex_queries.js"></script>
<script src="../../src/sha1.amd.js"></script> <script src="../../src/sha1.amd.js"></script>
<script src="../../src/jio.storage/s3storage.js"></script> <script src="../../src/jio.storage/s3storage.js"></script>
<script src="../../src/jio.storage/splitstorage.js"></script>
<script src="../jio/util.js"></script> <script src="../jio/util.js"></script>
</head> </head>
<body> <body>
...@@ -35,6 +36,7 @@ location.href.split('?')[1].split('&').forEach(function (item) { ...@@ -35,6 +36,7 @@ location.href.split('?')[1].split('&').forEach(function (item) {
</form> </form>
<br /> <br />
<div id="qunit"></div> <div id="qunit"></div>
<script src="s3storage.tests.js"></script> <!--<script src="s3storage.tests.js"></script>-->
<script src="split.s3storage.tests.js"></script>
</body> </body>
</html> </html>
/*jslint indent: 2, maxlen: 80, nomen: true */ /*jslint indent: 2, maxlen: 80, nomen: true */
/*global module, test, stop, start, expect, ok, deepEqual, location, sinon, /*global module, test, stop, start, expect, ok, deepEqual, location, sinon,
davstorage_spec, RSVP, jIO, test_util, dav_storage, btoa */ davstorage_spec, RSVP, jIO, test_util, dav_storage, btoa, s3storage_spec */
(function () { (function () {
"use strict"; "use strict";
...@@ -9,11 +9,6 @@ ...@@ -9,11 +9,6 @@
if (typeof s3storage_spec === 'object') { if (typeof s3storage_spec === 'object') {
use_fake_server = false; use_fake_server = false;
spec = s3storage_spec; spec = s3storage_spec;
} else {
spec = dav_storage.createDescription(
"http://localhost",
"none"
);
} }
module("S3 Storage"); module("S3 Storage");
...@@ -198,35 +193,7 @@ ...@@ -198,35 +193,7 @@
responses.push([ responses.push([
200, 200,
{"Content-Type": "text/xml"}, {"Content-Type": "text/xml"},
'<?xml version="1.0" encoding="utf-8"?>' + ''
'<D:multistatus xmlns:D="DAV:">' +
'<D:response xmlns:lp2="http://apache.org/dav/props/" ' +
'xmlns:lp1="DAV:">' +
'<D:href>/uploads/</D:href>' +
'<D:propstat>' +
'<D:prop>' +
'<lp1:resourcetype><D:collection/></lp1:resourcetype>' +
'<lp1:creationdate>2013-09-19T11:54:43Z</lp1:creationdate>' +
'<lp1:getlastmodified>Thu, 19 Sep 2013 11:54:43 GMT' +
'</lp1:getlastmodified>' +
'<lp1:getetag>"240be-1000-4e6bb3840a9ac"</lp1:getetag>' +
'<D:supportedlock>' +
'<D:lockentry>' +
'<D:lockscope><D:exclusive/></D:lockscope>' +
'<D:locktype><D:write/></D:locktype>' +
'</D:lockentry>' +
'<D:lockentry>' +
'<D:lockscope><D:shared/></D:lockscope>' +
'<D:locktype><D:write/></D:locktype>' +
'</D:lockentry>' +
'</D:supportedlock>' +
'<D:lockdiscovery/>' +
'<D:getcontenttype>httpd/unix-directory</D:getcontenttype>' +
'</D:prop>' +
'<D:status>HTTP/1.1 200 OK</D:status>' +
'</D:propstat>' +
'</D:response>' +
'</D:multistatus>'
]); // PROPFIND ]); // PROPFIND
return jio.allDocs(); return jio.allDocs();
} }
...@@ -899,4 +866,7 @@ ...@@ -899,4 +866,7 @@
}); });
module("SplitStorage + S3 Storage");
}()); }());
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment