diff --git a/config/default.json b/config/default.json index 78588d9..024bef3 100644 --- a/config/default.json +++ b/config/default.json @@ -22,14 +22,14 @@ "id":"uid" }, "hypertopic":{ - "uid": "id", - "displayName": "name", - "jpegPhoto": "thumbnail" + "uid": ["id"], + "displayName": ["name"], + "jpegPhoto": ["thumbnail", "resource"] }, "reserved":{ "attributes":{ - "dn":0, - "uid":0, + "dn":0, + "uid":0, "controls":0 }, "values":{ diff --git a/index.js b/index.js index f52d3de..d0cdb1a 100644 --- a/index.js +++ b/index.js @@ -18,8 +18,14 @@ var payload = { for (var attribute in entry) { if (!(attribute in config.reserved.attributes || entry[attribute] in config.reserved.values)) { var value = {}; - value[config.hypertopic[attribute]||attribute] = entry[attribute]; - this.rows.push({ + if(config.hypertopic[attribute]){ + for(var indexAttribute in config.hypertopic[attribute]){ + value[config.hypertopic[attribute][indexAttribute]] = entry[attribute]; + } + }else{ + value[attribute] = entry[attribute]; + } + this.rows.push({ key: key, value: value }); @@ -37,7 +43,7 @@ function sendItems(request, response) { filter = '(&' + filter + '('+ config.ldap.id + '=' + request.params.item + '))'; } var options = { - scope: 'sub', + scope: 'sub', filter: filter, attributes: config.ldap.attributes }; @@ -55,8 +61,21 @@ function sendItems(request, response) { }); } +function sendEmpty(request, response){ + response.json({rows: []}); +} + +function sendUser(request, response){ + response.json({rows: [{ + key:'annuaire', + value:{"corpus":{"id":"student", "name":"Étudiants"}} + }]}); +} + app.use(cors) -.get(['/corpus/:corpus', '/item/:corpus/:item'], sendItems); +.get(['/corpus/:corpus', '/item/:corpus/:item'], sendItems) +.get('/viewpoint/:viewpoint', sendEmpty) +.get('/user/annuaire', sendUser); app.listen(config.port); console.log('Server running on port ' + config.port);