@@ -215,9 +215,10 @@ func ZipResource(resource string) (*bytes.Buffer, error) {
215215 return buf , err ;
216216}
217217
218- func AddCatalog (network * net.Network , resource string ) (map [ string ] models.CatalogEntitySummary , error ) {
218+ func AddCatalog (network * net.Network , resource string ) (* models.CatalogBundleAddResult , error ) {
219219 urlString := "/v1/catalog"
220- var entities map [string ]models.CatalogEntitySummary
220+ urlStringWithDetail := urlString + "?detail=true"
221+ var result models.CatalogBundleAddResult
221222
222223 //Force auto-detect by default
223224 contentType := "application/octet-stream"
@@ -255,19 +256,25 @@ func AddCatalog(network *net.Network, resource string) (map[string]models.Catalo
255256 if err != nil {
256257 return nil , err
257258 }
258- body , err := network .SendPostRequestWithContentType (urlString , buf .Bytes (), "application/x-zip" )
259+ body , err := network .SendPostRequestWithContentType (urlStringWithDetail , buf .Bytes (), "application/x-zip" )
259260 if err != nil {
260261 return nil , err
261262 }
262- err = json .Unmarshal (body , & entities )
263- return entities , err
263+ err = json .Unmarshal (body , & result )
264+ if result .Code == "" {
265+ // older version of server, doesn't support detail
266+ err = json .Unmarshal (body , & result .Types )
267+ }
268+ return & result , err
264269 } else {
265270 extension := filepath .Ext (resource )
266271 lowercaseExtension := strings .ToLower (extension )
267272 if lowercaseExtension == ".zip" {
268273 contentType = "application/x-zip"
274+ urlString = urlStringWithDetail
269275 } else if lowercaseExtension == ".jar" {
270276 contentType = "application/x-jar"
277+ urlString = urlStringWithDetail
271278 }
272279 }
273280
@@ -277,9 +284,12 @@ func AddCatalog(network *net.Network, resource string) (map[string]models.Catalo
277284 if err != nil {
278285 return nil , err
279286 }
280- err = json .Unmarshal (body , & entities )
281-
282- return entities , err
287+ err = json .Unmarshal (body , & result )
288+ if result .Code == "" {
289+ // detail API not supported, just store the types
290+ err = json .Unmarshal (body , & result .Types )
291+ }
292+ return & result , err
283293}
284294
285295func GetLocation (network * net.Network , locationId string ) (models.CatalogItemSummary , error ) {
0 commit comments