public List < MenuIntegrityError > checkMenuIntegrity ( ) { List < MenuIntegrityError > errorList = new ArrayList <> ( ) ; Map < String , MenuEntry > links = new HashMap <> ( ) ; Map < String , MenuEntry > templates = new HashMap <> ( ) ; // check for duplicates, but only if menu has no submenu, otherwise o // link will be generated for ( AdminComponent comp : adminTool . getComponents ( ) ) { if ( null != comp . getMainMenu ( ) ) { comp . getMainMenu ( ) . flattened ( ) . forEach ( menu -> { if ( links . containsKey ( menu . getName ( ) ) && CollectionUtils . isEmpty ( menu . getSubmenu ( ) ) ) { findErrorAndAddEntry ( "duplicate link name on menu item" , MSG_KEY_DUPLICATE_LINK , errorList , menu , links . get ( menu . getName ( ) ) ) ; } else { links . put ( menu . getName ( ) , menu ) ; } if ( templates . containsKey ( menu . getTarget ( ) ) && CollectionUtils . isEmpty ( menu . getSubmenu ( ) ) ) { findErrorAndAddEntry ( "duplicate template reference on menu item" , MSG_KEY_DUPLICATE_TPL_REF , errorList , menu , templates . get ( menu . getTarget ( ) ) ) ; } else { templates . put ( menu . getTarget ( ) , menu ) ; } if ( config . isInternationalizationEnabled ( ) && StringUtils . isEmpty ( menu . getResouceMessageKey ( ) ) ) { findErrorAndAddEntry ( "missing message resource key on menu item" , MSG_KEY_MISSING_RESOURCE_KEY , errorList , menu , templates . get ( menu . getTarget ( ) ) ) ; } } ) ; } else { findErrorAndAddEntry ( String . format ( "the component '%s' has no main menu" , comp . getDisplayName ( ) ) , MSG_KEY_COMPONENT_NO_MAINMENU , errorList , null , null ) ; } } links . clear ( ) ; templates . clear ( ) ; return errorList ; }
checks for integrity errors