[Groonga-commit] groonga/gcs [master] createDeleteIndexFieldResponse with xmlbuilder

Back to archive index

null+****@clear***** null+****@clear*****
2012年 7月 19日 (木) 13:42:49 JST


Yoji SHIDARA	2012-07-19 13:42:49 +0900 (Thu, 19 Jul 2012)

  New Revision: 80fb01b93306e5e29c51cc57930388f2899ffd5a
  https://github.com/groonga/gcs/commit/80fb01b93306e5e29c51cc57930388f2899ffd5a

  Log:
    createDeleteIndexFieldResponse with xmlbuilder

  Modified files:
    lib/api/2011-02-01/configuration.js

  Modified: lib/api/2011-02-01/configuration.js (+16 -7)
===================================================================
--- lib/api/2011-02-01/configuration.js    2012-07-19 12:40:11 +0900 (eb4b61a)
+++ lib/api/2011-02-01/configuration.js    2012-07-19 13:42:49 +0900 (4309979)
@@ -3,6 +3,7 @@ var nroonga = require('../../wrapped-nroonga');
 var Domain = require('../../database').Domain;
 var Translator = require('../../batch/translator').Translator;
 var dateFormat = require('dateformat');
+var xmlbuilder = require('xmlbuilder');
 
 exports.version = path.basename(__dirname);
 
@@ -215,13 +216,21 @@ handlers.DefineIndexField = function(context, request, response) {
 };
 
 function createDeleteIndexFieldResponse(options) {
-  return '<?xml version="1.0"?>\n' +
-         '<DeleteIndexFieldResponse xmlns="' + XMLNS + '">' +
-           '<DeleteIndexFieldResult/>' +
-           '<ResponseMetadata>' +
-             '<RequestId>' + (options.requestId || '') + '</RequestId>' +
-           '</ResponseMetadata>' +
-         '</DeleteIndexFieldResponse>';
+  var doc = xmlbuilder.create();
+
+  // This is a workaround for the problem that text() does not work when empty string is given.
+  // https://github.com/oozcitak/xmlbuilder-js/pull/19
+  var requestId = doc.begin('DeleteIndexFieldResponse', {version: '1.0'}).attribute('xmlns', XMLNS)
+    .element('DeleteIndexFieldResult')
+    .up()
+    .element('ResponseMetadata')
+      .element('RequestId');
+
+  if (options.requestId && options.requestId !== '') {
+    requestId.text(options.requestId);
+  }
+
+  return doc.toString();
 }
 
 handlers.DeleteIndexField = function(context, request, response) {
-------------- next part --------------
HTML$B$NE:IU%U%!%$%k$rJ]4I$7$^$7$?(B...
Télécharger 



Groonga-commit メーリングリストの案内
Back to archive index