YUKI Hiroshi
null+****@clear*****
Wed Nov 21 17:23:49 JST 2012
YUKI Hiroshi 2012-11-21 17:23:49 +0900 (Wed, 21 Nov 2012) New Revision: 5dfcf83aaa433fefe555dffb4ef45427b0b4a192 https://github.com/groonga/gcs/commit/5dfcf83aaa433fefe555dffb4ef45427b0b4a192 Log: Validate domains before creation correctly Modified files: lib/api/2011-02-01/configuration.js lib/database/domain.js Modified: lib/api/2011-02-01/configuration.js (+6 -8) =================================================================== --- lib/api/2011-02-01/configuration.js 2012-11-21 17:17:34 +0900 (3b0603c) +++ lib/api/2011-02-01/configuration.js 2012-11-21 17:23:49 +0900 (32068f8) @@ -157,7 +157,7 @@ function createDomainStatus(options) { handlers.CreateDomain = function(context, request, response, config) { var domain = handleDomanValidationError(function() { - return new Domain(request.query.DomainName || '', context); + return new Domain(request.query.DomainName || '', context).validate(); }); if (!domain.exists()) domain.createSync(); @@ -171,7 +171,7 @@ handlers.CreateDomain = function(context, request, response, config) { handlers.DeleteDomain = function(context, request, response, config) { var domain = handleDomanValidationError(function() { - return new Domain(request.query.DomainName || '', context); + return new Domain(request.query.DomainName || '', context).validate(); }); var result; if (domain.exists()) { @@ -326,7 +326,7 @@ function getFieldOption(option, request, type) { handlers.DefineIndexField = function(context, request, response, config) { var domainName = request.query.DomainName || ''; var domain = handleDomanValidationError(function() { - return new Domain(domainName, context); + return new Domain(domainName, context).validate(); }); if (!domain || !domain.exists()) throw new errors.ResourceNotFoundError('Domain not found: ' + domainName); @@ -334,9 +334,7 @@ handlers.DefineIndexField = function(context, request, response, config) { var fieldName = request.query['IndexField.IndexFieldName'] || ''; var fieldType = request.query['IndexField.IndexFieldType'] || ''; var field = handleIndexFieldValidationError(function() { - var field = domain.getIndexField(fieldName); - field.type = fieldType; - return field; + return domain.getIndexField(fieldName).setType(type).validate(); }); assertValidFieldOptions(request, fieldType, domainName); @@ -368,14 +366,14 @@ handlers.DefineIndexField = function(context, request, response, config) { handlers.DeleteIndexField = function(context, request, response, config) { var domain = handleDomanValidationError(function() { - return new Domain(request.query.DomainName || '', context); + return new Domain(request.query.DomainName || '', context).validate(); }); if (!domain || !domain.exists()) throw new errors.ResourceNotFoundError('Domain not found: ' + domainName); var fieldName = request.query['IndexFieldName'] || ''; var field = handleIndexFieldValidationError(function() { - return domain.getIndexField(fieldName); + return domain.getIndexField(fieldName).validate(); }, { NAME_FIELD: 'indexFieldName' }); Modified: lib/database/domain.js (+0 -3) =================================================================== --- lib/database/domain.js 2012-11-21 17:17:34 +0900 (2b7f5e6) +++ lib/database/domain.js 2012-11-21 17:23:49 +0900 (45633ab) @@ -134,9 +134,6 @@ Domain.prototype = { this.context = context && new nroonga.Context(context); this.initializeNameAndId(source); - - // for validation - this.tableName; }, initializeNameAndId: function(source) { if (typeof source == 'string') { -------------- next part -------------- HTML����������������������������...Download