Navigation Menu

Skip to content

Commit

Permalink
Build DomainStatus from domain information
Browse files Browse the repository at this point in the history
  • Loading branch information
piro committed Aug 1, 2012
1 parent edc66cd commit 0ea48f4
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 26 deletions.
40 changes: 14 additions & 26 deletions lib/api/2011-02-01/configuration.js
Expand Up @@ -35,26 +35,26 @@ function createDomainStatus(options) {
.element('Created').text(options.created || 'false').up()
.element('Deleted').text(options.deleted || 'false').up()
.element('DocService')
.element('Endpoint').text(options.documentsEndpoint || '').up()
.element('Endpoint').text(options.domain.getDocumentsEndpoint(options.hostname)).up()
.up()
.element('DomainId')
.text(options.domainId + '/' + options.domainName)
.text(options.domain.domainId)
.up()
.element('DomainName').text(options.domainName).up()
.element('DomainName').text(options.domain.name).up()
.element('NumSearchableDocs')
.text(options.searchableDocumentsCount || '0')
.text(options.domain.searchableDocumentsCount)
.up()
.element('RequiresIndexDocuments')
.text(options.requiresIndexDocuments || 'false')
.text(options.domain.requiresIndexDocuments)
.up()
.element('SearchInstanceCount')
.text(options.searchInstanceCount || '0')
.text(options.domain.searchInstanceCount)
.up()
.element('SearchPartitionCount')
.text(options.searchPartitionCount || '0')
.text(options.domain.searchPartitionCount)
.up()
.element('SearchService')
.element('Endpoint').text(options.searchEndpoint || '').up()
.element('Endpoint').text(options.domain.getSearchEndpoint(options.hostname)).up()
.up();
return domainStatus;
}
Expand All @@ -80,15 +80,9 @@ handlers.CreateDomain = function(context, request, response) {
host = host ? '.' + host : '';
response.contentType('application/xml');
response.send(createCreateDomainResponse({
domainName: domain.name,
domainId: domain.id,
searchEndpoint: 'search-' + domain.name + '-' + domain.id + host,
documentsEndpoint: 'doc-' + domain.name + '-' + domain.id + host,
created: true,
searchableDocumentsCount: 0,
searchInstanceCount: 0,
searchPartitionCount: 0,
requiresIndexDocuments: false
domain: domain,
hostname: host,
created: true
}));
} catch (error) {
var body = createCommonErrorResponse('InternalFailure', error);
Expand Down Expand Up @@ -118,15 +112,9 @@ handlers.DeleteDomain = function(context, request, response) {
host = host ? '.' + host : '';
response.contentType('application/xml');
response.send(createDeleteDomainResponse({
domainName: domain.name,
domainId: domain.id,
searchEndpoint: 'search-' + domain.name + '-' + domain.id + host,
documentsEndpoint: 'doc-' + domain.name + '-' + domain.id + host,
deleted: true,
searchableDocumentsCount: 0,
searchInstanceCount: 0,
searchPartitionCount: 0,
requiresIndexDocuments: false
domain: domain,
hostname: host,
deleted: true
}));
} catch (error) {
var body = createCommonErrorResponse('InternalFailure', error.message);
Expand Down
23 changes: 23 additions & 0 deletions lib/database/domain.js
Expand Up @@ -124,6 +124,29 @@ Domain.prototype = {
get id() {
return FAKE_DOMAIN_ID;
},
get domainId() {
return this.id + '/' + this.name;
},

get searchableDocumentsCount() {
return 0;
},
get requiresIndexDocuments() {
return false;
},
get searchInstanceCount() {
return 0;
},
get searchPartitionCount() {
return 0;
},

getDocumentsEndpoint: function(hostname) {
return 'doc-' + this.name + '-' + this.id + hostname;
},
getSearchEndpoint: function(hostname) {
return 'search-' + this.name + '-' + this.id + hostname;
},

createSync: function() {
if (!this.context)
Expand Down

0 comments on commit 0ea48f4

Please sign in to comment.