@@ -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
@@ -905,6 +944,12 @@ def get_all_components(self, fields=None, page=-1, page_size=-1):
905944 if not resp :
906945 return None
907946
947+ if "_embedded" not in resp :
948+ return None
949+
950+ if "sw360:components" not in resp ["_embedded" ]:
951+ return None
952+
908953 resp = resp ["_embedded" ]["sw360:components" ]
909954 return resp
910955
@@ -925,6 +970,12 @@ def get_components_by_type(self, component_type):
925970 if not resp :
926971 return None
927972
973+ if "_embedded" not in resp :
974+ return None
975+
976+ if "sw360:components" not in resp ["_embedded" ]:
977+ return None
978+
928979 resp = resp ["_embedded" ]["sw360:components" ]
929980 return resp
930981
@@ -1148,6 +1199,12 @@ def get_all_vendors(self):
11481199 if not resp :
11491200 return None
11501201
1202+ if "_embedded" not in resp :
1203+ return None
1204+
1205+ if "sw360:vendors" not in resp ["_embedded" ]:
1206+ return None
1207+
11511208 resp = resp ["_embedded" ]["sw360:vendors" ]
11521209 return resp
11531210
@@ -1265,6 +1322,13 @@ def get_attachment_infos_for_resource(self, resource_type, resource_id):
12651322 + resource_id
12661323 + "/attachments"
12671324 )
1325+
1326+ if "_embedded" not in resp :
1327+ return None
1328+
1329+ if "sw360:attachments" not in resp ["_embedded" ]:
1330+ return None
1331+
12681332 resp = resp ["_embedded" ]["sw360:attachments" ]
12691333 return resp
12701334
@@ -1500,6 +1564,12 @@ def get_all_licenses(self):
15001564 if not resp :
15011565 return None
15021566
1567+ if "_embedded" not in resp :
1568+ return None
1569+
1570+ if "sw360:licenses" not in resp ["_embedded" ]:
1571+ return None
1572+
15031573 resp = resp ["_embedded" ]["sw360:licenses" ]
15041574 return resp
15051575
0 commit comments