Package com.dotcms.repackage.org.json

Examples of com.dotcms.repackage.org.json.JSONArray


        response.getWriter().flush();
    }

    private JSONObject getAllWordSuggestions(JSONObject params) throws SpellCheckException, JSONException {
        JSONObject suggestions = new JSONObject();
        JSONArray checkedWords = params.optJSONArray("words");
        String lang = params.optString("lang");
        lang = ("".equals(lang)) ? DEFAULT_LANGUAGE : lang;
        List<String> misspelledWords = findMisspelledWords(new JsonArrayIterator(checkedWords), lang);
        for (String misspelledWord : misspelledWords) {
            List<String> suggestionsList = findSuggestions(misspelledWord, lang, maxSuggestionsCount);
View Full Code Here


          Logger.error(TinyMCESpellCheckerServlet.class,"Failed to send error response to client", e);
        }
    }

    private JSONArray checkWords(JSONArray params) throws SpellCheckException {
        JSONArray misspelledWords = new JSONArray();
        if (params != null) {
            JSONArray checkedWords = params.optJSONArray(1);
            String lang = params.optString(0);
            lang = ("".equals(lang)) ? DEFAULT_LANGUAGE : lang;

            List<String> misspelledWordsList = findMisspelledWords(new JsonArrayIterator(checkedWords), lang);
View Full Code Here

        }
        return misspelledWords;
    }

    private JSONArray getWordSuggestions(JSONArray params) throws SpellCheckException {
        JSONArray suggestions = new JSONArray();
        if (params != null) {
            String lang = params.optString(0);
            lang = ("".equals(lang)) ? DEFAULT_LANGUAGE : lang;
            String word = params.optString(1);
            List<String> suggestionsList = findSuggestions(word, lang, maxSuggestionsCount);
            for (String suggestion : suggestionsList) {
                suggestions.put(suggestion);
            }
        }
        return suggestions;
    }
View Full Code Here

    @Path("/all/{params:.*}")
    @Produces(MediaType.APPLICATION_JSON)
    public Response getAll(@Context HttpServletRequest request, @PathParam("params") String params) {
        init(params, true, request, true, "9");
        try {
            JSONArray array=new JSONArray();

            for ( Map<String, Object> lic : LicenseUtil.getLicenseRepoList() ) {
                JSONObject obj = new JSONObject();
                for ( Map.Entry<String, Object> entry : lic.entrySet() ) {

                    //Lets exclude some data we don' want/need to expose
                    if ( entry.getKey().equals( "serverid" ) ) {
                        obj.put( entry.getKey(), entry.getValue() != null ? LicenseUtil.getDisplayServerId( (String) lic.get( "serverId" ) ) : "" );
                        obj.put( "fullserverid", entry.getValue() != null ? entry.getValue() : "" );
                    } else if ( entry.getKey().equals( "serverId" ) || entry.getKey().equals( "license" ) ) {
                        //Just ignore these fields
                    } else if ( entry.getKey().equals( "id" ) ) {
                        obj.put( entry.getKey(), entry.getKey() != null ? entry.getValue() : "" );
                        obj.put( "idDisplay", entry.getValue() != null ? LicenseUtil.getDisplaySerial( (String) entry.getValue() ) : "" );
                    } else {
                        obj.put( entry.getKey(), entry.getKey() != null ? entry.getValue() : "" );
                    }

                }
                array.put( obj );
            }
           
            return Response.ok(array.toString(), MediaType.APPLICATION_JSON_TYPE).build();
        }
        catch(Exception ex) {
            Logger.error(this, "can't get all license on repo", ex);
            return Response.serverError().build();
        }
View Full Code Here

        try {
            //Getting our current logs
            List<LogMapperRow> logList = LogMapper.getInstance().getLogList();

            //Preparing a json response
            JSONArray logsJSONArray = new JSONArray();

            for ( LogMapperRow logMapperRow : logList ) {

                JSONObject jsonLogMapperRow = new JSONObject();
                jsonLogMapperRow.put( "name", logMapperRow.getLog_name() );
                jsonLogMapperRow.put( "enabled", logMapperRow.getEnabled() );
                jsonLogMapperRow.put( "description", logMapperRow.getDescription() );

                //Add it to our json array
                logsJSONArray.put( jsonLogMapperRow );
            }

            //Preparing the json response
            jsonResponse.put( "logs", logsJSONArray );
            jsonResponse.put( "response", "sucess" );
View Full Code Here

TOP

Related Classes of com.dotcms.repackage.org.json.JSONArray

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.