Skip to content

Commit

Permalink
Don't return index field status for not-existing fields by DescribeIn…
Browse files Browse the repository at this point in the history
…dexFields
  • Loading branch information
piroor committed Oct 18, 2012
1 parent 3747d4e commit 3715095
Showing 1 changed file with 20 additions and 22 deletions.
42 changes: 20 additions & 22 deletions lib/api/2011-02-01/configuration.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,17 @@ exports.version = path.basename(__dirname);
var XMLNS = 'http://cloudsearch.amazonaws.com/doc/2011-02-01';

function createCommonErrorResponse(errorCode, error) {
if (error.message) {
error = error.message + '\n' + error.stack;
} else {
error = error.toString();
}
var doc = xmlbuilder.create();
doc.begin('Response', { version: '1.0' })
.element('Errors')
.element('Error')
.element('Code').text(errorCode).up()
.element('Message').text((error.message || error).toString()).up()
.element('Message').text(error).up()
.up()
.up()
.element('RequestID').text(uuid.v4()).up();
Expand Down Expand Up @@ -121,8 +126,7 @@ handlers.DeleteDomain = function(context, request, response, config) {
response.contentType('application/xml');
response.send(createGenericResponse('DeleteDomain', result));
} catch (error) {
var body = createCommonErrorResponse('InternalFailure',
(error.message || error).toString());
var body = createCommonErrorResponse('InternalFailure', error);
response.contentType('application/xml');
response.send(body, 400);
}
Expand Down Expand Up @@ -164,8 +168,7 @@ handlers.DescribeDomains = function(context, request, response, config) {
response.contentType('application/xml');
response.send(createGenericResponse('DescribeDomains', result));
} catch (error) {
var body = createCommonErrorResponse('InternalFailure',
(error.message || error).toString());
var body = createCommonErrorResponse('InternalFailure', error);
response.contentType('application/xml');
response.send(body, 400);
}
Expand Down Expand Up @@ -270,8 +273,7 @@ handlers.DefineIndexField = function(context, request, response, config) {
response.contentType('application/xml');
response.send(createGenericResponse('DefineIndexField', result));
} catch (error) {
var body = createCommonErrorResponse('InternalFailure',
(error.message || error).toString());
var body = createCommonErrorResponse('InternalFailure', error);
response.contentType('application/xml');
response.send(body, 400);
}
Expand All @@ -287,8 +289,7 @@ handlers.DeleteIndexField = function(context, request, response, config) {
response.contentType('application/xml');
response.send(createGenericResponse('DeleteIndexField'));
} catch (error) {
var body = createCommonErrorResponse('InternalFailure',
(error.message || error).toString());
var body = createCommonErrorResponse('InternalFailure', error);
response.contentType('application/xml');
response.send(body, 400);
}
Expand Down Expand Up @@ -318,15 +319,17 @@ handlers.DescribeIndexFields = function(context, request, response, config) {
});
var fields = fieldNames.length ?
fieldNames.map(function(name) {
return domain.getIndexField(name);
var field = domain.getIndexField(name);
return field.exists() ? field : null ;
}).filter(function(field) {
return field;
}) :
domain.indexFields ;
var result = createIndexFields(fields);
response.contentType('application/xml');
response.send(createGenericResponse('DescribeIndexFields', result));
} catch (error) {
var body = createCommonErrorResponse('InternalFailure',
(error.message || error).toString());
var body = createCommonErrorResponse('InternalFailure', error);
response.contentType('application/xml');
response.send(body, 400);
}
Expand Down Expand Up @@ -357,8 +360,7 @@ handlers.IndexDocuments = function(context, request, response, config) {
response.contentType('application/xml');
response.send(createGenericResponse('IndexDocuments', result));
} catch (error) {
var body = createCommonErrorResponse('InternalFailure',
(error.message || error).toString());
var body = createCommonErrorResponse('InternalFailure', error);
response.contentType('application/xml');
response.send(body, 400);
}
Expand Down Expand Up @@ -397,8 +399,7 @@ handlers.UpdateSynonymOptions = function(context, request, response, config) {
response.contentType('application/xml');
response.send(createGenericResponse('UpdateSynonymOptions', result));
} catch (error) {
var body = createCommonErrorResponse('InternalFailure',
(error.message || error).toString());
var body = createCommonErrorResponse('InternalFailure', error);
response.contentType('application/xml');
response.send(body, 400);
}
Expand All @@ -416,8 +417,7 @@ handlers.DescribeSynonymOptions = function(context, request, response, config) {
response.contentType('application/xml');
response.send(createGenericResponse('DescribeSynonymOptions', result));
} catch (error) {
var body = createCommonErrorResponse('InternalFailure',
(error.message || error).toString());
var body = createCommonErrorResponse('InternalFailure', error);
response.contentType('application/xml');
response.send(body, 400);
}
Expand Down Expand Up @@ -452,8 +452,7 @@ handlers.UpdateDefaultSearchField = function(context, request, response, config)
response.contentType('application/xml');
response.send(createGenericResponse('UpdateDefaultSearchField', result));
} catch (error) {
var body = createCommonErrorResponse('InternalFailure',
(error.message || error).toString());
var body = createCommonErrorResponse('InternalFailure', error);
response.contentType('application/xml');
response.send(body, 400);
}
Expand All @@ -472,8 +471,7 @@ handlers.DescribeDefaultSearchField = function(context, request, response, confi
response.contentType('application/xml');
response.send(createGenericResponse('DescribeDefaultSearchField', result));
} catch (error) {
var body = createCommonErrorResponse('InternalFailure',
(error.message || error).toString());
var body = createCommonErrorResponse('InternalFailure', error);
response.contentType('application/xml');
response.send(body, 400);
}
Expand Down

0 comments on commit 3715095

Please sign in to comment.