Commit d7efabc2 authored by Sebastien Robin's avatar Sebastien Robin

rename secondstorage to sub_storage

parent 6b2cdf90
......@@ -3,18 +3,18 @@ var newConflictManagerStorage = function ( spec, my ) {
var that = my.basicStorage( spec, my ), priv = {};
var storage_exists = (spec.storage?true:false);
priv.secondstorage_spec = spec.storage || {type:'base'};
priv.secondstorage_string = JSON.stringify (priv.secondstorage_spec);
priv.sub_storage_spec = spec.storage || {type:'base'};
priv.sub_storage_string = JSON.stringify (priv.sub_storage_spec);
var local_namespace = 'jio/conflictmanager/'+
priv.secondstorage_string+'/';
priv.sub_storage_string+'/';
var empty_fun = function (){};
var super_serialized = that.serialized;
that.serialized = function () {
var o = super_serialized();
o.storage = priv.secondstorage_spec;
o.storage = priv.sub_storage_spec;
return o;
};
......@@ -28,29 +28,29 @@ var newConflictManagerStorage = function ( spec, my ) {
priv.getDistantMetadata = function (command,path,success,error) {
var cloned_option = command.cloneOption ();
cloned_option.metadata_only = false;
that.addJob ('get',priv.secondstorage_spec,path,cloned_option,
that.addJob ('get',priv.sub_storage_spec,path,cloned_option,
success, error);
};
priv.saveMetadataToDistant = function (command,path,content,success,error) {
that.addJob ('put',priv.secondstorage_spec,
that.addJob ('put',priv.sub_storage_spec,
{_id:path,content:JSON.stringify (content)},
command.cloneOption(),success,error);
};
priv.saveNewRevision = function (command,path,content,success,error) {
that.addJob ('post',priv.secondstorage_spec,{_id:path,content:content},
that.addJob ('post',priv.sub_storage_spec,{_id:path,content:content},
command.cloneOption(),success,error);
};
priv.loadRevision = function (command,path,success,error) {
that.addJob('get',priv.secondstorage_spec,path,command.cloneOption(),
that.addJob('get',priv.sub_storage_spec,path,command.cloneOption(),
success, error);
};
priv.deleteAFile = function (command,path,success,error) {
var cloned_option = command.cloneOption();
that.addJob ('remove',priv.secondstorage_spec,{_id:path},
that.addJob ('remove',priv.sub_storage_spec,{_id:path},
command.cloneOption(), success, error);
};
......@@ -654,7 +654,7 @@ var newConflictManagerStorage = function ( spec, my ) {
am.call(o,'error',[error]);
};
cloned_option.metadata_only = true;
that.addJob ('allDocs',priv.secondstorage_spec,null,cloned_option,
that.addJob ('allDocs',priv.sub_storage_spec,null,cloned_option,
success,error);
};
o.filterTheList = function (result) {
......
......@@ -6,15 +6,15 @@ var newCryptedStorage = function ( spec, my ) {
priv.username = spec.username || '';
priv.password = spec.password || '';
priv.secondstorage_spec = spec.storage || {type:'base'};
priv.secondstorage_string = JSON.stringify (priv.secondstorage_string);
priv.sub_storage_spec = spec.storage || {type:'base'};
priv.sub_storage_string = JSON.stringify (priv.sub_storage_string);
var super_serialized = that.serialized;
that.serialized = function () {
var o = super_serialized();
o.username = priv.username;
o.password = priv.password; // TODO : unsecured !!!
o.storage = priv.secondstorage_string;
o.storage = priv.sub_storage_string;
return o;
};
......@@ -129,7 +129,7 @@ var newCryptedStorage = function ( spec, my ) {
cloned_doc = command.cloneDoc();
cloned_doc._id = new_file_name;
cloned_doc.content = new_file_content;
that.addJob ('put',priv.secondstorage_spec,cloned_doc,
that.addJob ('put',priv.sub_storage_spec,cloned_doc,
command.cloneOption(),success,error);
};
am.wait(o,'save',1);
......@@ -150,7 +150,7 @@ var newCryptedStorage = function ( spec, my ) {
});
};
o.get = function () {
that.addJob('get',priv.secondstorage_spec,new_file_name,
that.addJob('get',priv.sub_storage_spec,new_file_name,
command.cloneOption(),o.success,o.error);
};
o.success = function (val) {
......@@ -181,7 +181,7 @@ var newCryptedStorage = function ( spec, my ) {
that.allDocs = function (command) {
var result_array = [], am = priv.newAsyncModule(), o = {};
o.allDocs = function () {
that.addJob ('allDocs', priv.secondstorage_spec, null,
that.addJob ('allDocs', priv.sub_storage_spec, null,
command.cloneOption(), o.onSuccess, o.error);
};
o.onSuccess = function (val) {
......@@ -247,7 +247,7 @@ var newCryptedStorage = function ( spec, my ) {
o.removeDocument = function () {
var cloned_doc = command.cloneDoc();
cloned_doc._id = new_file_name;
that.addJob ('remove', priv.secondstorage_spec, cloned_doc,
that.addJob ('remove', priv.sub_storage_spec, cloned_doc,
command.cloneOption(), o.success, that.error);
};
o.success = function (val) {
......
......@@ -2,23 +2,23 @@ var newIndexStorage = function ( spec, my ) {
spec = spec || {};
var that = my.basicStorage( spec, my ), priv = {};
var validatestate_secondstorage = spec.storage || false;
priv.secondstorage_spec = spec.storage || {type:'base'};
priv.secondstorage_string = JSON.stringify (priv.secondstorage_spec);
var validatestate_sub_storage = spec.storage || false;
priv.sub_storage_spec = spec.storage || {type:'base'};
priv.sub_storage_string = JSON.stringify (priv.sub_storage_spec);
var storage_object_name = 'jio/indexed_storage_object';
var storage_file_object_name = 'jio/indexed_file_object/'+
priv.secondstorage_string;
priv.sub_storage_string;
var super_serialized = that.serialized;
that.serialized = function () {
var o = super_serialized();
o.storage = priv.secondstorage_spec;
o.storage = priv.sub_storage_spec;
return o;
};
that.validateState = function () {
if (!validatestate_secondstorage) {
if (!validatestate_sub_storage) {
return 'Need at least one parameter: "storage" '+
'containing storage specifications.';
}
......@@ -38,7 +38,7 @@ var newIndexStorage = function ( spec, my ) {
priv.indexStorage = function () {
var obj = localStorage.getItem (storage_object_name) || {};
obj[priv.secondstorage_spec] = new Date().getTime();
obj[priv.sub_storage_spec] = new Date().getTime();
localStorage.setItem (storage_object_name,obj);
};
......@@ -99,7 +99,7 @@ var newIndexStorage = function ( spec, my ) {
var success = function (val) {
priv.setFileArray(val.rows);
};
that.addJob ('allDocs', priv.secondstorage_spec,null,
that.addJob ('allDocs', priv.sub_storage_spec,null,
{max_retry:3},success,function(){});
};
......@@ -122,7 +122,7 @@ var newIndexStorage = function ( spec, my ) {
that.error(err);
};
priv.indexStorage();
that.addJob ('put',priv.secondstorage_spec,cloned_doc,
that.addJob ('put',priv.sub_storage_spec,cloned_doc,
cloned_option,success,error);
}; // end put
......@@ -140,7 +140,7 @@ var newIndexStorage = function ( spec, my ) {
},
get = function () {
var cloned_option = command.cloneOption();
that.addJob ('get',priv.secondstorage_spec,command.cloneDoc(),
that.addJob ('get',priv.sub_storage_spec,command.cloneDoc(),
cloned_option,success,error);
that.end();
};
......@@ -181,7 +181,7 @@ var newIndexStorage = function ( spec, my ) {
error = function (err) {
that.error(err);
};
that.addJob ('allDocs', priv.secondstorage_spec,null,
that.addJob ('allDocs', priv.sub_storage_spec,null,
command.cloneOption(),success,error);
}
}; // end allDocs
......@@ -199,7 +199,7 @@ var newIndexStorage = function ( spec, my ) {
error = function (err) {
that.error(err);
};
that.addJob ('remove',priv.secondstorage_spec,command.cloneDoc(),
that.addJob ('remove',priv.sub_storage_spec,command.cloneDoc(),
command.cloneOption(),success,error);
}; // end remove
......
......@@ -4,7 +4,7 @@
* Description:
* {
* "type": "revision",
* "secondstorage": <sub storage description>
* "sub_storage": <sub storage description>
* }
*/
jIO.addStorageType('revision', function (spec, my) {
......@@ -13,7 +13,7 @@ jIO.addStorageType('revision', function (spec, my) {
spec = spec || {};
that = my.basicStorage(spec, my);
priv.substorage_key = "secondstorage";
priv.substorage_key = "sub_storage";
priv.doctree_suffix = ".revision_tree.json";
priv.substorage = spec[priv.substorage_key];
......
......@@ -3,8 +3,8 @@
var newWaitStorage = function ( spec, my ) {
var that = my.basicStorage( spec, my ), priv = {};
var validatestate_secondstorage = spec.storage || false;
priv.secondstorage_spec = spec.storage || {type:'base'};
var validatestate_sub_storage = spec.storage || false;
priv.sub_storage_spec = spec.storage || {type:'base'};
priv.delay = spec.delay || 5000;
priv.save = spec.save || true;
priv.load = spec.load || false;
......@@ -12,7 +12,7 @@
priv.remove = spec.remove || false;
that.validateState = function () {
if (!validatestate_secondstorage) {
if (!validatestate_sub_storage) {
return 'Need at least one parameter: "storage" '+
'containing storage specifications.';
}
......@@ -22,7 +22,7 @@
that.specToStore = function () {
var o = {};
o.delay = priv.delay;
o.storage = priv.secondstorage_spec;
o.storage = priv.sub_storage_spec;
o.save = priv.save;
o.load = priv.load;
o.getlist = priv.getlist;
......@@ -36,7 +36,7 @@
delay = priv.delay;
}
setTimeout (function () {
that.addJob ( that.newStorage(priv.secondstorage_spec),
that.addJob ( that.newStorage(priv.sub_storage_spec),
command );
that.end();
}, delay);
......
......@@ -1084,7 +1084,7 @@ test ("Post", function(){
o.jio = JIO.newJio({
"type": "revision",
"secondstorage": {
"sub_storage": {
"type": "local",
"username": "urevpost",
"applicationname": "arevpost"
......@@ -1156,7 +1156,7 @@ test ("Put", function(){
o.jio = JIO.newJio({
"type": "revision",
"secondstorage": {
"sub_storage": {
"type": "local",
"username": "urevput",
"applicationname": "arevput"
......@@ -1215,7 +1215,7 @@ test ("Get", function(){
o.jio = JIO.newJio({
"type": "revision",
"secondstorage": {
"sub_storage": {
"type": "local",
"username": "urevget",
"applicationname": "arevget"
......@@ -1369,7 +1369,7 @@ test ("Remove", function(){
o.jio = JIO.newJio({
"type": "revision",
"secondstorage": {
"sub_storage": {
"type": "local",
"username": "urevrem",
"applicationname": "arevrem"
......@@ -1572,7 +1572,7 @@ test ("Scenario", function(){
o.jio = JIO.newJio({
"type": "revision",
"secondstorage": {
"sub_storage": {
"type": "local",
"username": "usam1",
"applicationname": "asam1"
......@@ -1598,7 +1598,7 @@ test ("Scenario", function(){
// open new tab (JIO)
o.jio2 = JIO.newJio({
"type": "revision",
"secondstorage": {
"sub_storage": {
"type": "local",
"username": "usam1",
"applicationname": "asam1"
......@@ -1655,7 +1655,7 @@ test ("Scenario", function(){
// Reopen JIO
o.jio = JIO.newJio({
"type": "revision",
"secondstorage": {
"sub_storage": {
"type": "local",
"username": "usam1",
"applicationname": "asam1"
......@@ -2213,11 +2213,11 @@ test ('Get document list', function () {
test ('Remove document', function () {
var o = {}; o.clock = this.sandbox.useFakeTimers();
o.clock.tick(base_tick);
o.secondstorage = {type:'dummyall3tries',username:'indexremove'}
o.sub_storage = {type:'dummyall3tries',username:'indexremove'}
o.storage_file_object_name = 'jio/indexed_file_object/'+
JSON.stringify (o.secondstorage);
JSON.stringify (o.sub_storage);
o.jio = JIO.newJio({type:'indexed',storage:o.secondstorage});
o.jio = JIO.newJio({type:'indexed',storage:o.sub_storage});
o.f = function (err,val) {
if (err) {
err = err.status;
......@@ -2586,12 +2586,12 @@ test ('Revision Conflict', function() {
ok (!LocalOrCookieStorage.getItem(o.localNamespace + string),
message || '"' + string + '" does not exists.');
};
o.secondstorage_spec = {type:'local',
o.sub_storage_spec = {type:'local',
username:'revisionconflict',
applicationname:'jiotests'}
//////////////////////////////////////////////////////////////////////
o.jio = JIO.newJio({type:'conflictmanager',
storage:o.secondstorage_spec});
storage:o.sub_storage_spec});
// create a new file
o.spy(o,'value',
{ok:true,id:'file.doc',rev:'1',conflicts:{total_rows:0,rows:[]},
......@@ -2750,12 +2750,12 @@ test ('Conflict in a conflict solving', function () {
ok (!LocalOrCookieStorage.getItem(o.localNamespace + string),
message || '"' + string + '" does not exists.');
};
o.secondstorage_spec = {type:'local',
o.sub_storage_spec = {type:'local',
username:'conflictconflict',
applicationname:'jiotests'}
//////////////////////////////////////////////////////////////////////
o.jio = JIO.newJio({type:'conflictmanager',
storage:o.secondstorage_spec});
storage:o.sub_storage_spec});
// create a new file
o.test_message = 'new file "file.doc", revision: "0".'
o.f = o.t.spy();
......@@ -2937,12 +2937,12 @@ test ('Remove revision conflict', function () {
ok (!LocalOrCookieStorage.getItem(o.localNamespace + string),
message || '"' + string + '" does not exists.');
};
o.secondstorage_spec = {type:'local',
o.sub_storage_spec = {type:'local',
username:'removeconflict',
applicationname:'jiotests'}
//////////////////////////////////////////////////////////////////////
o.jio = JIO.newJio({type:'conflictmanager',
storage:o.secondstorage_spec});
storage:o.sub_storage_spec});
o.test_message = 'new file "file.doc", revision: "0".';
o.f = o.t.spy();
......@@ -3167,12 +3167,12 @@ test ('Load Revisions', function () {
o.clock.tick (base_tick);
o.spy = basic_spy_function;
o.tick = basic_tick_function;
o.secondstorage_spec = {type:'local',
o.sub_storage_spec = {type:'local',
username:'loadrevisions',
applicationname:'jiotests'}
//////////////////////////////////////////////////////////////////////
o.jio = JIO.newJio({type:'conflictmanager',
storage:o.secondstorage_spec});
storage:o.sub_storage_spec});
o.spy(o,'status',404,'load file rev:1,','f'); // 12 === Replaced
o.spy(o,'status',404,'load file rev:2','g');
o.spy(o,'status',404,'and load file rev:3 at the same time','h');
......@@ -3188,13 +3188,13 @@ test ('Get revision List', function () {
o.clock.tick (base_tick);
o.spy = basic_spy_function;
o.tick = basic_tick_function;
o.secondstorage_spec = {type:'local',
o.sub_storage_spec = {type:'local',
username:'getrevisionlist',
applicationname:'jiotests'}
o.rev = {};
//////////////////////////////////////////////////////////////////////
o.jio = JIO.newJio({type:'conflictmanager',
storage:o.secondstorage_spec});
storage:o.sub_storage_spec});
o.spy(o,'value',{total_rows:0,rows:[]},'Get revision list');
o.jio.allDocs(o.f);
o.tick(o);
......
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