static PluginValidation validatePluginMeta ( final PluginMeta pluginList , final File file ) { PluginValidation . State state = PluginValidation . State . VALID ; if ( pluginList == null ) { return PluginValidation . builder ( ) . message ( "No metadata" ) . state ( PluginValidation . State . INVALID ) . build ( ) ; } List < String > messages = new ArrayList <> ( ) ; if ( null == pluginList . getName ( ) ) { messages . add ( "'name' not found in metadata" ) ; state = PluginValidation . State . INVALID ; } if ( null == pluginList . getVersion ( ) ) { messages . add ( "'version' not found in metadata" ) ; state = PluginValidation . State . INVALID ; } if ( null == pluginList . getRundeckPluginVersion ( ) ) { messages . add ( "'rundeckPluginVersion' not found in metadata" ) ; state = PluginValidation . State . INVALID ; } else if ( ! SUPPORTED_PLUGIN_VERSIONS . contains ( pluginList . getRundeckPluginVersion ( ) ) ) { messages . add ( "'rundeckPluginVersion': \"" + pluginList . getRundeckPluginVersion ( ) + "\" is not supported" ) ; state = PluginValidation . State . INVALID ; } if ( pluginList . getRundeckPluginVersion ( ) . equals ( VERSION_2_0 ) ) { List < String > validationErrors = new ArrayList <> ( ) ; PluginValidation . State hostCompatState = PluginMetadataValidator . validateTargetHostCompatibility ( validationErrors , pluginList . getTargetHostCompatibility ( ) ) ; PluginValidation . State versCompatState = PluginMetadataValidator . validateRundeckCompatibility ( validationErrors , pluginList . getRundeckCompatibilityVersion ( ) ) ; messages . addAll ( validationErrors ) ; state = state . or ( hostCompatState ) . or ( versCompatState ) ; } final List < ProviderDef > pluginDefs = pluginList . getPluginDefs ( ) ; for ( final ProviderDef pluginDef : pluginDefs ) { try { validateProviderDef ( pluginDef ) ; } catch ( PluginException e ) { messages . add ( e . getMessage ( ) ) ; state = PluginValidation . State . INVALID ; } } return PluginValidation . builder ( ) . state ( state ) . messages ( messages ) . build ( ) ; }
Return true if loaded metadata about the plugin file is valid .