protected Response getConfiguration ( final String extensionId , final Sid accountSid , final MediaType responseType ) { //Parameter "extensionId" could be the extension Sid or extension name. ExtensionConfiguration extensionConfiguration = null ; ExtensionConfiguration extensionAccountConfiguration = null ; Sid extensionSid = null ; String extensionName = null ; if ( Sid . pattern . matcher ( extensionId ) . matches ( ) ) { extensionSid = new Sid ( extensionId ) ; } else { extensionName = extensionId ; } if ( Sid . pattern . matcher ( extensionId ) . matches ( ) ) { try { extensionConfiguration = extensionsConfigurationDao . getConfigurationBySid ( extensionSid ) ; } catch ( Exception e ) { return status ( NOT_FOUND ) . build ( ) ; } } else { try { extensionConfiguration = extensionsConfigurationDao . getConfigurationByName ( extensionName ) ; } catch ( Exception e ) { return status ( NOT_FOUND ) . build ( ) ; } } if ( accountSid != null ) { if ( extensionSid == null ) { extensionSid = extensionConfiguration . getSid ( ) ; } try { extensionAccountConfiguration = extensionsConfigurationDao . getAccountExtensionConfiguration ( accountSid . toString ( ) , extensionSid . toString ( ) ) ; extensionConfiguration . setConfigurationData ( extensionAccountConfiguration . getConfigurationData ( ) , extensionAccountConfiguration . getConfigurationType ( ) ) ; } catch ( Exception e ) { return status ( NOT_FOUND ) . build ( ) ; } } if ( extensionConfiguration == null ) { return status ( NOT_FOUND ) . build ( ) ; } else { if ( APPLICATION_XML_TYPE . equals ( responseType ) ) { final RestCommResponse response = new RestCommResponse ( extensionConfiguration ) ; return ok ( xstream . toXML ( response ) , APPLICATION_XML ) . build ( ) ; } else if ( APPLICATION_JSON_TYPE . equals ( responseType ) ) { return ok ( gson . toJson ( extensionConfiguration ) , APPLICATION_JSON ) . build ( ) ; } else { return null ; } } }
Will be used to get configuration for extension