Commit 7e0db3ad authored by Vincent Bechu's avatar Vincent Bechu

erp5_officejs: commit fix_storage

/reviewed-on !313
parent bf94f426
......@@ -11,7 +11,8 @@
return RSVP.all([
gadget.getSetting("portal_type"),
gadget.getSetting("erp5_attachment_synchro", undefined),
gadget.getSetting("default_view_reference", "jio_view")
gadget.getSetting("default_view_reference", "jio_view"),
gadget.getSetting("storage_attachment_issue", false)
]);
})
.push(function (result) {
......@@ -19,6 +20,7 @@
portal_type = result[0],
attachment_synchro = result[1] !== undefined,
extended_attachment_url = result[1];
configuration = {
type: "replicate",
// XXX This drop the signature lists...
......@@ -41,8 +43,6 @@
check_remote_creation: true,
check_remote_deletion: true,
local_sub_storage: {
type: "fix_local",
sub_storage: {
type: "query",
sub_storage: {
type: "uuid",
......@@ -51,7 +51,6 @@
database: "officejs-erp5"
}
}
}
},
remote_sub_storage: {
type: "mapping",
......@@ -78,11 +77,22 @@
}
}
};
// This is only for onlyoffice
if (extended_attachment_url === "/{+id}/Document_downloadForOnlyOfficeApp") {
configuration = {
type: "fix_local",
is_fixed: result[3],
sub_storage: configuration
};
}
return gadget.setSetting('jio_storage_description', configuration);
})
.push(function () {
return gadget.setSetting('jio_storage_name', "ERP5");
})
.push(function () {
return gadget.setSetting('storage_attachment_issue', true);
})
.push(function () {
return gadget.setGlobalSetting('erp5_url', erp5_url);
})
......
......@@ -273,7 +273,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>960.25496.14411.56081</string> </value>
<value> <string>960.32726.32486.40567</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -291,7 +291,7 @@
</tuple>
<state>
<tuple>
<float>1498834693.92</float>
<float>1499160764.83</float>
<string>UTC</string>
</tuple>
</state>
......
/*globals jIO, Blob, Rusha, RSVP, URI*/
/*jslint indent: 2, maxlen: 80, nomen: true*/
(function (jIO, Blob, Rusha, RSVP, URI) {
"use strict";
var rusha = new Rusha(), stringify = jIO.util.stringify;
function CompatibilityStorage(spec) {
this._sub_storage = jIO.createJIO(spec.sub_storage);
this._is_fixed = spec.is_fixed;
}
CompatibilityStorage.prototype.get = function () {
return this._sub_storage.get.apply(this._sub_storage, arguments);
};
CompatibilityStorage.prototype.put = function () {
return this._sub_storage.put.apply(this._sub_storage, arguments);
};
CompatibilityStorage.prototype.post = function () {
return this._sub_storage.post.apply(this._sub_storage, arguments);
};
CompatibilityStorage.prototype.remove = function () {
return this._sub_storage.remove.apply(this._sub_storage, arguments);
};
CompatibilityStorage.prototype.hasCapacity = function () {
return this._sub_storage.hasCapacity.apply(this._sub_storage, arguments);
};
CompatibilityStorage.prototype.repair = function () {
var context = this;
// Here fix the local storage for some cases.
if (!context._is_fixed) {
return context._sub_storage.allDocs({
select_list: ["content_type"]
})
.push(function (result) {
var i, promise_list = [], doc_list = result.data.rows;
for (i = 0; i < result.data.total_rows; i += 1) {
if (doc_list[i].value.content_type !== undefined &&
!doc_list[i].value.content_type.startsWith("application/x-asc")) {
promise_list.push(
context._sub_storage.remove(doc_list[i].id)
);
}
}
return RSVP.all(promise_list);
})
.push(function () {
return context._sub_storage.repair.apply(
context._sub_storage, arguments
);
});
}
};
CompatibilityStorage.prototype.allAttachments = function (doc_id) {
return this._sub_storage.allAttachments.apply(
this._sub_storage,
arguments
);
};
CompatibilityStorage.prototype.getAttachment = function (doc_id) {
var context = this;
return context._sub_storage.getAttachment.apply(
this._sub_storage,
arguments
);
};
CompatibilityStorage.prototype.putAttachment = function () {
return this._sub_storage.putAttachment.apply(this._sub_storage, arguments);
};
CompatibilityStorage.prototype.removeAttachment = function () {
return this._sub_storage.removeAttachment.apply(
this._sub_storage,
arguments
);
};
CompatibilityStorage.prototype.buildQuery = function () {
return this._sub_storage.buildQuery.apply(
this._sub_storage,
arguments
);
};
jIO.addStorage('fix_local', CompatibilityStorage);
}(jIO, Blob, Rusha, RSVP, URI));
\ No newline at end of file
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