public void getSpellcheckingResult ( final HttpServletResponse res , final ServletRequest servletRequest , final CmsObject cms ) throws CmsPermissionViolationException , IOException { // Perform a permission check performPermissionCheck ( cms ) ; // Set the appropriate response headers setResponeHeaders ( res ) ; // Figure out whether a JSON or HTTP request has been sent CmsSpellcheckingRequest cmsSpellcheckingRequest = null ; try { String requestBody = getRequestBody ( servletRequest ) ; final JSONObject jsonRequest = new JSONObject ( requestBody ) ; cmsSpellcheckingRequest = parseJsonRequest ( jsonRequest ) ; } catch ( Exception e ) { LOG . debug ( e . getMessage ( ) , e ) ; cmsSpellcheckingRequest = parseHttpRequest ( servletRequest , cms ) ; } if ( ( null != cmsSpellcheckingRequest ) && cmsSpellcheckingRequest . isInitialized ( ) ) { // Perform the actual spellchecking final SpellCheckResponse spellCheckResponse = performSpellcheckQuery ( cmsSpellcheckingRequest ) ; /* * The field spellCheckResponse is null when exactly one correctly spelled word is passed to the spellchecker. * In this case it's safe to return an empty JSON formatted map, as the passed word is correct. Otherwise, * convert the spellchecker response into a new JSON formatted map. */ if ( null == spellCheckResponse ) { cmsSpellcheckingRequest . m_wordSuggestions = new JSONObject ( ) ; } else { cmsSpellcheckingRequest . m_wordSuggestions = getConvertedResponseAsJson ( spellCheckResponse ) ; } } // Send response back to the client sendResponse ( res , cmsSpellcheckingRequest ) ; }
Performs spellchecking using Solr and returns the spellchecking results using JSON .