Commit 2784ba5a authored by Sven Franck's avatar Sven Franck

Merge branch 'attachments' of https://git.erp5.org/repos/jio into attachments

parents 1771adbe 4b3851ae
......@@ -21,15 +21,11 @@ var command = function(spec, my) {
priv.tried = 0;
priv.doc = spec.doc || {};
priv.doc._id = priv.doc._id || generateUuid();
priv.doc._id = priv.doc._id;
priv.docid = spec.docid || '';
// xxx fixed spec.content to spec.doc.content for PUTATTACHMENT
// xxx need extra check for GET, otherwise spec.doc is undefined
console.log("COMMAND");
console.log( spec );
console.log( spec.doc );
console.log( spec.doc.content );
priv.content = spec.doc === undefined ? undefined :
typeof spec.doc.content === 'string'?
spec.doc.content:
......
......@@ -11,8 +11,6 @@ var putAttachmentCommand = function(spec, my) {
that.executeOn = function (storage) {
storage.putAttachment (that);
};
console.log("putAttachmentCommand");
console.log( typeof that.getContent() );
that.validateState = function () {
if (typeof that.getContent() !== 'string') {
that.error({
......
var jio = function(spec) {
var generateUuid = function () {
var S4 = function () {
var i, string = Math.floor(
Math.random() * 0x10000 /* 65536 */
).toString(16);
for (i = string.length; i < 4; i += 1) {
string = '0'+string;
}
return string;
};
return S4() + S4() + "-" +
S4() + "-" +
S4() + "-" +
S4() + "-" +
S4() + S4() + S4();
};
......@@ -147,11 +147,6 @@
};
priv.parametersToObject = function (list, default_options) {
console.log("aloha");
console.log("what do we have");
console.log( list );
console.log( default_options );
var k, i = 0, callbacks = [], param = {options:{}};
for (i = 0; i < list.length; i += 1) {
if (typeof list[i] === 'object') {
......@@ -353,7 +348,7 @@
{max_retry: 0}
);
priv.addJob(putAttachmentCommand,{
priv.addJob(putAttachmentCommand,{
doc:{_id:id,content:doc,_rev:rev,mimetype:mimetype},
options:param.options,
callbacks:{success:param.success,error:param.error}
......
......@@ -14,6 +14,28 @@ var storage = function(spec, my) {
}
});
/**
* Generate a new uuid
* @method generateUuid
* @return {string} The new uuid
*/
that.generateUuid = function () {
var S4 = function () {
var i, string = Math.floor(
Math.random() * 0x10000 /* 65536 */
).toString(16);
for (i = string.length; i < 4; i += 1) {
string = '0'+string;
}
return string;
};
return S4() + S4() + "-" +
S4() + "-" +
S4() + "-" +
S4() + "-" +
S4() + S4() + S4();
};
/**
* Generates a hash code of a string
* @method hashCode
......@@ -232,6 +254,15 @@ var storage = function(spec, my) {
});
};
that._putAttachment = function () {
setTimeout(function () {
that.error(that.createErrorObject(
0,"Not Implemented Yet",
"\"PutAttachment\" command is not implemented"
));
});
};
that._get = function () {
setTimeout(function () {
that.error(that.createErrorObject(
......@@ -240,7 +271,7 @@ var storage = function(spec, my) {
});
};
that._alldocs = function () {
that._allDocs = function () {
setTimeout(function () {
that.error(that.createErrorObject(
0,"Not Implemented Yet",
......
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