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
......@@ -604,7 +604,7 @@
that.XHRwrapper(command, docId, '', 'GET', mime, '', isJIO, false);
};
that.getAttachment = function (command,param,option) {
that.getAttachment = function (command,param,option) {
var docId, attachId, isJIO, mime;
function getTheAttachment(){
......@@ -848,7 +848,8 @@
function putDocument() {
var data, doc;
data = JSON.parse(my_document);
//data = JSON.parse(my_document);
data = my_document;
doc = priv.updateMeta(data, docId, attachId, "remove", '');
that.XHRwrapper(command, docId, '', 'PUT', mime, doc,
false, false, function (reponse) {
......@@ -860,18 +861,35 @@
function getDocument() {
that.XHRwrapper(command, docId, '', 'GET', mime, '', false, false,
function (response) {
my_document = response;
if (JSON.parse(my_document)._attachments[attachId] !== undefined){
putDocument();
} else {
if (response == '404'){
return command.error(
404,
"missing attachment",
"This Attachment does not exist"
);
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();
} else {
return command.error(
404,
"missing attachment",
"This Attachment does not exist"
);
}
}
}
}
);
);
}
getDocument();
};
......@@ -882,7 +900,7 @@
* @param {object} command The JIO command
**/
that.allDocs = function (command) {
that.allDocs = function (command, param, options) {
var my_document, mime;
my_document = null;
mime = 'text/plain; charset=UTF-8';
......@@ -946,11 +964,6 @@
errCallback = function (err) {
if (err.status === 404) {
//status
//statustext "Not Found"
//error
//reason "reason"
//message "did not work"
err.error = "not_found";
command.error(err);
} else {
......@@ -960,81 +973,60 @@
i = resultTable.length - 1;
///* JONR : what is the replacement for command.getOption ? */
// if (command.getOption("include_docs") === true) {
// for (i; i >= 0; i -= 1) {
// keyId = resultTable[i];
// Signature = that.encodeAuthorization(keyId);
// 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 {
///*TRISTANC :
//allDocs = function (command, param, options) {
//if (options.include_docs) {
if (options.include_docs) {
for (i; i >= 0; i -= 1) {
keyId = resultTable[i];
Signature = that.encodeAuthorization(keyId);
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) {
keyId = resultTable[i];
allDocResponse.rows[i] = {
"id": priv.fileNameToIds(keyId).join(),
"key": priv.fileNameToIds(keyId).join(),
"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);
//}
}
}
function getXML() {
......
This diff is collapsed.
This diff is collapsed.
......@@ -98,6 +98,8 @@ JobQueue.prototype.repair = function () {
* @return {Number} The generated id
*/
JobQueue.prototype.post = function (job) {
console.log('jio core');
console.log(job);
var i, next = 1;
// get next id
for (i = 0; i < this._array.length; i += 1) {
......
......@@ -13,6 +13,7 @@
<script src="../../complex_queries.js"></script>
<script src="../../src/sha1.amd.js"></script>
<script src="../../src/jio.storage/s3storage.js"></script>
<script src="../../src/jio.storage/splitstorage.js"></script>
<script src="../jio/util.js"></script>
</head>
<body>
......@@ -35,6 +36,7 @@ location.href.split('?')[1].split('&').forEach(function (item) {
</form>
<br />
<div id="qunit"></div>
<script src="s3storage.tests.js"></script>
<!--<script src="s3storage.tests.js"></script>-->
<script src="split.s3storage.tests.js"></script>
</body>
</html>
/*jslint indent: 2, maxlen: 80, nomen: true */
/*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 () {
"use strict";
......@@ -9,11 +9,6 @@
if (typeof s3storage_spec === 'object') {
use_fake_server = false;
spec = s3storage_spec;
} else {
spec = dav_storage.createDescription(
"http://localhost",
"none"
);
}
module("S3 Storage");
......@@ -198,35 +193,7 @@
responses.push([
200,
{"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
return jio.allDocs();
}
......@@ -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