@@ -267,6 +267,13 @@ def get_projects_by_type(self, project_type):
267267 :raises SW360Error: if there is a negative HTTP response
268268 """
269269 resp = self .api_get (self .url + "resource/api/projects?type=" + project_type )
270+
271+ if "_embedded" not in resp :
272+ return None
273+
274+ if "sw360:projects" not in resp ["_embedded" ]:
275+ return None
276+
270277 resp = resp ["_embedded" ]["sw360:projects" ]
271278 return resp
272279
@@ -280,8 +287,16 @@ def get_project_names(self):
280287 :raises SW360Error: if there is a negative HTTP response
281288 """
282289 projects = self .get_projects ()
283- projects = projects ["_embedded" ]["sw360:projects" ]
284290 resp = []
291+
292+ if "_embedded" not in projects :
293+ return resp
294+
295+ if "sw360:projects" not in projects ["_embedded" ]:
296+ return resp
297+
298+ projects = projects ["_embedded" ]["sw360:projects" ]
299+
285300 for key in projects :
286301 resp .append (key ["name" ] + ", " + key ["version" ])
287302
@@ -302,6 +317,12 @@ def get_projects_by_name(self, name):
302317 if not resp :
303318 return None
304319
320+ if "_embedded" not in resp :
321+ return None
322+
323+ if "sw360:projects" not in resp ["_embedded" ]:
324+ return None
325+
305326 resp = resp ["_embedded" ]["sw360:projects" ]
306327 return resp
307328
@@ -324,6 +345,12 @@ def get_projects_by_external_id(self, ext_id_name, ext_id_value=""):
324345 if not resp :
325346 return None
326347
348+ if "_embedded" not in resp :
349+ return None
350+
351+ if "sw360:projects" not in resp ["_embedded" ]:
352+ return None
353+
327354 resp = resp ["_embedded" ]["sw360:projects" ]
328355 return resp
329356
@@ -346,6 +373,12 @@ def get_projects_by_group(self, group, all_details=False):
346373 if not resp :
347374 return None
348375
376+ if "_embedded" not in resp :
377+ return None
378+
379+ if "sw360:projects" not in resp ["_embedded" ]:
380+ return None
381+
349382 resp = resp ["_embedded" ]["sw360:projects" ]
350383 return resp
351384
@@ -365,6 +398,12 @@ def get_projects_by_tag(self, tag):
365398 if not resp :
366399 return None
367400
401+ if "_embedded" not in resp :
402+ return None
403+
404+ if "sw360:projects" not in resp ["_embedded" ]:
405+ return None
406+
368407 resp = resp ["_embedded" ]["sw360:projects" ]
369408 return resp
370409
@@ -891,6 +930,12 @@ def get_all_components(self, fields=None, page=-1, page_size=-1):
891930 if not resp :
892931 return None
893932
933+ if "_embedded" not in resp :
934+ return None
935+
936+ if "sw360:components" not in resp ["_embedded" ]:
937+ return None
938+
894939 resp = resp ["_embedded" ]["sw360:components" ]
895940 return resp
896941
@@ -911,6 +956,12 @@ def get_components_by_type(self, component_type):
911956 if not resp :
912957 return None
913958
959+ if "_embedded" not in resp :
960+ return None
961+
962+ if "sw360:components" not in resp ["_embedded" ]:
963+ return None
964+
914965 resp = resp ["_embedded" ]["sw360:components" ]
915966 return resp
916967
@@ -1134,6 +1185,12 @@ def get_all_vendors(self):
11341185 if not resp :
11351186 return None
11361187
1188+ if "_embedded" not in resp :
1189+ return None
1190+
1191+ if "sw360:vendors" not in resp ["_embedded" ]:
1192+ return None
1193+
11371194 resp = resp ["_embedded" ]["sw360:vendors" ]
11381195 return resp
11391196
@@ -1251,6 +1308,13 @@ def get_attachment_infos_for_resource(self, resource_type, resource_id):
12511308 + resource_id
12521309 + "/attachments"
12531310 )
1311+
1312+ if "_embedded" not in resp :
1313+ return None
1314+
1315+ if "sw360:attachments" not in resp ["_embedded" ]:
1316+ return None
1317+
12541318 resp = resp ["_embedded" ]["sw360:attachments" ]
12551319 return resp
12561320
@@ -1486,6 +1550,12 @@ def get_all_licenses(self):
14861550 if not resp :
14871551 return None
14881552
1553+ if "_embedded" not in resp :
1554+ return None
1555+
1556+ if "sw360:licenses" not in resp ["_embedded" ]:
1557+ return None
1558+
14891559 resp = resp ["_embedded" ]["sw360:licenses" ]
14901560 return resp
14911561
0 commit comments