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) { ...@@ -21,15 +21,11 @@ var command = function(spec, my) {
priv.tried = 0; priv.tried = 0;
priv.doc = spec.doc || {}; priv.doc = spec.doc || {};
priv.doc._id = priv.doc._id || generateUuid(); priv.doc._id = priv.doc._id;
priv.docid = spec.docid || ''; priv.docid = spec.docid || '';
// xxx fixed spec.content to spec.doc.content for PUTATTACHMENT // xxx fixed spec.content to spec.doc.content for PUTATTACHMENT
// xxx need extra check for GET, otherwise spec.doc is undefined // 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 : priv.content = spec.doc === undefined ? undefined :
typeof spec.doc.content === 'string'? typeof spec.doc.content === 'string'?
spec.doc.content: spec.doc.content:
......
...@@ -11,8 +11,6 @@ var putAttachmentCommand = function(spec, my) { ...@@ -11,8 +11,6 @@ var putAttachmentCommand = function(spec, my) {
that.executeOn = function (storage) { that.executeOn = function (storage) {
storage.putAttachment (that); storage.putAttachment (that);
}; };
console.log("putAttachmentCommand");
console.log( typeof that.getContent() );
that.validateState = function () { that.validateState = function () {
if (typeof that.getContent() !== 'string') { if (typeof that.getContent() !== 'string') {
that.error({ that.error({
......
var jio = function(spec) { 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 @@ ...@@ -147,11 +147,6 @@
}; };
priv.parametersToObject = function (list, default_options) { 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:{}}; var k, i = 0, callbacks = [], param = {options:{}};
for (i = 0; i < list.length; i += 1) { for (i = 0; i < list.length; i += 1) {
if (typeof list[i] === 'object') { if (typeof list[i] === 'object') {
......
...@@ -14,6 +14,28 @@ var storage = function(spec, my) { ...@@ -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 * Generates a hash code of a string
* @method hashCode * @method hashCode
...@@ -232,6 +254,15 @@ var storage = function(spec, my) { ...@@ -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 () { that._get = function () {
setTimeout(function () { setTimeout(function () {
that.error(that.createErrorObject( that.error(that.createErrorObject(
...@@ -240,7 +271,7 @@ var storage = function(spec, my) { ...@@ -240,7 +271,7 @@ var storage = function(spec, my) {
}); });
}; };
that._alldocs = function () { that._allDocs = function () {
setTimeout(function () { setTimeout(function () {
that.error(that.createErrorObject( that.error(that.createErrorObject(
0,"Not Implemented Yet", 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