Commit 4763d057 authored by Romain Courteaud's avatar Romain Courteaud

ERP5 now returns jIO URN instead of HTTP URL.

parent 5901753b
This diff is collapsed.
...@@ -10,9 +10,9 @@ ...@@ -10,9 +10,9 @@
// } // }
/*jslint indent: 2, nomen: true, unparam: true */ /*jslint indent: 2, nomen: true, unparam: true */
/*global jIO, complex_queries, console, UriTemplate, FormData, RSVP */ /*global jIO, complex_queries, console, UriTemplate, FormData, RSVP, URI */
(function (jIO, complex_queries) { (function (jIO, complex_queries, URI) {
"use strict"; "use strict";
function ERP5Storage(spec) { function ERP5Storage(spec) {
...@@ -96,26 +96,9 @@ ...@@ -96,26 +96,9 @@
}); });
}).then(function (doc) { }).then(function (doc) {
// XXX Really depend on server response... // XXX Really depend on server response...
var new_document_url = doc.target.getResponseHeader("Location"); var uri = new URI(doc.target.getResponseHeader("X-Location"));
return jIO.util.ajax({ command.success({"id": uri.segment(2)});
"type": "GET", }).fail(function (error) {
"url": new_document_url,
"xhrFields": {
withCredentials: true
}
});
}).then(function (response) {
var doc_hal = JSON.parse(response.target.responseText);
if (doc_hal !== null) {
command.success({"id": doc_hal._relative_url});
} else {
command.error(
"not_found",
"missing",
"Cannot find document"
);
}
}, function (error) {
console.error(error); console.error(error);
command.error( command.error(
500, 500,
...@@ -193,15 +176,16 @@ ...@@ -193,15 +176,16 @@
var data = catalog_json._embedded.contents, var data = catalog_json._embedded.contents,
count = data.length, count = data.length,
i, i,
uri,
item, item,
result = [], result = [],
promise_list = [result]; promise_list = [result];
for (i = 0; i < count; i += 1) { for (i = 0; i < count; i += 1) {
item = data[i]; item = data[i];
item._id = item._relative_url; uri = new URI(item._links.self.href);
result.push({ result.push({
id: item._relative_url, id: uri.segment(2),
key: item._relative_url, key: uri.segment(2),
doc: {}, doc: {},
value: item value: item
}); });
...@@ -231,4 +215,4 @@ ...@@ -231,4 +215,4 @@
jIO.addStorage("erp5", ERP5Storage); jIO.addStorage("erp5", ERP5Storage);
}(jIO, complex_queries)); }(jIO, complex_queries, URI));
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