Merge pull request #1 from 30x/rj_XAPID-999

[XAPID-999] fix duplicate config in response, added configuration to …
diff --git a/api.go b/api.go
index fb614af..6dbdba3 100644
--- a/api.go
+++ b/api.go
@@ -380,6 +380,11 @@
 }
 
 func getHttpHost() string {
+
+	configuredEndpoint := config.GetString(configBundleBlobDownloadEndpoint)
+	if configuredEndpoint != "" {
+		return configuredEndpoint
+	}
 	// apid-core has to set this according to the protocol apid is to be run: http/https
 	proto := config.GetString(configProtocol)
 	if proto == "" {
diff --git a/data.go b/data.go
index 2aa7f13..ae7875b 100644
--- a/data.go
+++ b/data.go
@@ -136,26 +136,46 @@
 	return
 }
 
-// TODO there's a bug in the db statement
 func (dbc *dbManager) getReadyDeployments() ([]DataDeployment, error) {
 
-	rows, err := dbc.getDb().Query(`SELECT
-	a.id,
-	a.organization_id,
-	a.environment_id,
-	a.bean_blob_id,
-	a.resource_blob_id,
-	a.type,
-	a.name,
-	a.revision,
-	a.path,
-	a.created_at,
-	a.created_by,
-	a.updated_at,
-	a.updated_by
-	FROM metadata_runtime_entity_metadata as a
-	INNER JOIN apid_blob_available as b
-	ON (a.bean_blob_id = b.id OR a.resource_blob_id = b.id)
+	rows, err := dbc.getDb().Query(`
+		SELECT 	a.id,
+			a.organization_id,
+			a.environment_id,
+			a.bean_blob_id,
+			a.resource_blob_id,
+			a.type,
+			a.name,
+			a.revision,
+			a.path,
+			a.created_at,
+			a.created_by,
+			a.updated_at,
+			a.updated_by
+		FROM metadata_runtime_entity_metadata as a
+		WHERE a.id IN (
+			SELECT
+					a.id
+				FROM metadata_runtime_entity_metadata as a
+				INNER JOIN apid_blob_available as b
+				ON a.resource_blob_id = b.id
+				WHERE a.resource_blob_id != ""
+			INTERSECT
+				SELECT
+					a.id
+				FROM metadata_runtime_entity_metadata as a
+				INNER JOIN apid_blob_available as b
+				ON a.bean_blob_id = b.id
+				WHERE a.resource_blob_id != ""
+
+			UNION
+				SELECT
+					a.id
+				FROM metadata_runtime_entity_metadata as a
+				INNER JOIN apid_blob_available as b
+				ON a.bean_blob_id = b.id
+				WHERE a.resource_blob_id = ""
+		)
 	;
 	`)
 
diff --git a/init.go b/init.go
index 0d2376d..d27b566 100644
--- a/init.go
+++ b/init.go
@@ -25,20 +25,21 @@
 )
 
 const (
-	configProtocol              = "protocol_type"
-	configAPIListen             = "api_listen"
-	configBundleDirKey          = "gatewaydeploy_bundle_dir"
-	configDebounceDuration      = "gatewaydeploy_debounce_duration"
-	configBundleCleanupDelay    = "gatewaydeploy_bundle_cleanup_delay"
-	configMarkDeployFailedAfter = "gatewaydeploy_deployment_timeout"
-	configDownloadConnTimeout   = "gatewaydeploy_download_connection_timeout"
-	configApiServerBaseURI      = "apigeesync_proxy_server_base"
-	configApidInstanceID        = "apigeesync_apid_instance_id"
-	configApidClusterID         = "apigeesync_cluster_id"
-	configConcurrentDownloads   = "apigeesync_concurrent_downloads"
-	configDownloadQueueSize     = "apigeesync_download_queue_size"
-	configBlobServerBaseURI     = "apigeesync_blob_server_base"
-	configStoragePath           = "local_storage_path"
+	configProtocol                   = "protocol_type"
+	configAPIListen                  = "api_listen"
+	configBundleBlobDownloadEndpoint = "gatewaydeploy_bundle_download_endpoint"
+	configBundleDirKey               = "gatewaydeploy_bundle_dir"
+	configDebounceDuration           = "gatewaydeploy_debounce_duration"
+	configBundleCleanupDelay         = "gatewaydeploy_bundle_cleanup_delay"
+	configMarkDeployFailedAfter      = "gatewaydeploy_deployment_timeout"
+	configDownloadConnTimeout        = "gatewaydeploy_download_connection_timeout"
+	configApiServerBaseURI           = "apigeesync_proxy_server_base"
+	configApidInstanceID             = "apigeesync_apid_instance_id"
+	configApidClusterID              = "apigeesync_cluster_id"
+	configConcurrentDownloads        = "apigeesync_concurrent_downloads"
+	configDownloadQueueSize          = "apigeesync_download_queue_size"
+	configBlobServerBaseURI          = "apigeesync_blob_server_base"
+	configStoragePath                = "local_storage_path"
 )
 
 var (