@@ -298,8 +298,49 @@ public JSONObject getAuditReport(DashboardAuditRequest dashboardAuditRequest) {
298
298
businessApplication , businessService , auditType , identifierName , identifierVersion , identifierUrl );
299
299
if (Objects .nonNull (auditReport ) && Objects .nonNull (auditReport .getAuditResponse ())) {
300
300
return (JSONObject ) auditReport .getAuditResponse ();
301
+ }else {
302
+ Cmdb busServItem = cmdbRepository .findByConfigurationItemAndItemType (businessService , "app" );
303
+ Cmdb busAppItem = cmdbRepository .findByConfigurationItemAndItemType (businessApplication , "component" );
304
+
305
+ if (busServItem == null ){
306
+ JSONObject invalidBAResponse = createLookupResponseWhenEmpty (DashboardAuditStatus .DASHBOARD_INVALID_BA , businessApplication , businessService );
307
+ return invalidBAResponse ;
308
+ }else if (busAppItem == null ){
309
+ JSONObject invalidComponentResponse = createLookupResponseWhenEmpty (DashboardAuditStatus .DASHBOARD_INVALID_COMPONENT , businessApplication , businessService );
310
+ return invalidComponentResponse ;
311
+ }else if (!componentInfoMatch (busServItem , businessApplication )){
312
+ JSONObject componentBAMismatchResponse = createLookupResponseWhenEmpty (DashboardAuditStatus .DASHBOARD_COMPONENT_BA_MISMATCH , businessApplication , businessService );
313
+ return componentBAMismatchResponse ;
314
+ }else {
315
+ JSONObject noDataResponse = createLookupResponseWhenEmpty (DashboardAuditStatus .DASHBOARD_AUDIT_NO_DATA , businessApplication , businessService );
316
+ return noDataResponse ;
317
+ }
318
+ }
319
+
320
+
321
+ }
322
+
323
+ private JSONObject createLookupResponseWhenEmpty (DashboardAuditStatus dashboardAuditStatus , String businessApplication , String businessService ){
324
+ JSONObject auditResponse = new JSONObject ();
325
+ auditResponse .put ("businessApplication" , businessApplication );
326
+ auditResponse .put ("businessService" , businessService );
327
+ auditResponse .put ("auditStatuses" , Collections .singleton (dashboardAuditStatus ));
328
+ auditResponse .put ("lastUpdated" , 0 );
329
+ auditResponse .put ("auditEntity" , new JSONObject ());
330
+ auditResponse .put ("review" , new JSONObject ());
331
+ return auditResponse ;
332
+ }
333
+
334
+ private boolean componentInfoMatch (Cmdb businessApplication , String businessService ){
335
+ if (businessApplication .getComponents () == null ){
336
+ return false ;
301
337
}
302
- return new JSONObject ();
338
+
339
+ if (businessApplication .getComponents ().contains (businessService )){
340
+ return true ;
341
+ }
342
+
343
+ return false ;
303
344
}
304
345
305
346
private void validateParameters (String dashboardTitle , DashboardType dashboardType , String businessService , String businessApp , long beginDate , long endDate ) throws AuditException {
0 commit comments