Search in sources :

Example 16 with JSONArray

use of org.json.simple.JSONArray in project histogram by bigmlcom.

the class SumResult method toJSON.

@SuppressWarnings("unchecked")
public JSONArray toJSON(DecimalFormat format) {
    JSONArray jsonArray = new JSONArray();
    jsonArray.add(Utils.roundNumber(_count, format));
    _targetSum.addJSON(jsonArray, format);
    return jsonArray;
}
Also used : JSONArray(org.json.simple.JSONArray)

Example 17 with JSONArray

use of org.json.simple.JSONArray in project jaggery by wso2.

the class TomcatJaggeryWebappsDeployer method addServlets.

private static void addServlets(Context ctx, JSONObject jaggeryConfig) {
    if (jaggeryConfig != null) {
        JSONArray arrServlets = (JSONArray) jaggeryConfig.get(JaggeryCoreConstants.JaggeryConfigParams.SERVLETS);
        JSONArray arrServletMappings = (JSONArray) jaggeryConfig.get(JaggeryCoreConstants.JaggeryConfigParams.SERVLET_MAPPINGS);
        if (arrServlets != null) {
            for (Object servletObj : arrServlets) {
                JSONObject servlet = (JSONObject) servletObj;
                String name = (String) servlet.get(JaggeryCoreConstants.JaggeryConfigParams.SERVLETS_NAME);
                String clazz = (String) servlet.get(JaggeryCoreConstants.JaggeryConfigParams.SERVLETS_CLASS);
                Wrapper servletWrapper = Tomcat.addServlet(ctx, name, clazz);
                JSONArray arrParams = (JSONArray) servlet.get(JaggeryCoreConstants.JaggeryConfigParams.SERVLETS_PARAMS);
                if (arrParams != null) {
                    for (Object paramObj : arrParams) {
                        JSONObject param = (JSONObject) paramObj;
                        String paramName = (String) param.get(JaggeryCoreConstants.JaggeryConfigParams.SERVLETS_PARAMS_NAME);
                        String paramValue = (String) param.get(JaggeryCoreConstants.JaggeryConfigParams.SERVLETS_PARAMS_VALUE);
                        servletWrapper.addInitParameter(paramName, paramValue);
                    }
                }
            }
        }
        if (arrServletMappings != null) {
            for (Object servletMappingObj : arrServletMappings) {
                JSONObject mapping = (JSONObject) servletMappingObj;
                String name = (String) mapping.get(JaggeryCoreConstants.JaggeryConfigParams.SERVLET_MAPPINGS_NAME);
                String url = (String) mapping.get(JaggeryCoreConstants.JaggeryConfigParams.SERVLET_MAPPINGS_URL);
                ctx.addServletMapping(url, name);
            }
        }
    }
}
Also used : Wrapper(org.apache.catalina.Wrapper) JSONObject(org.json.simple.JSONObject) JSONArray(org.json.simple.JSONArray) JSONObject(org.json.simple.JSONObject)

Example 18 with JSONArray

use of org.json.simple.JSONArray in project jaggery by wso2.

the class TomcatJaggeryWebappsDeployer method addContextParams.

private static void addContextParams(Context ctx, JSONObject jaggeryConfig) {
    if (jaggeryConfig != null) {
        JSONArray arrContextParams = (JSONArray) jaggeryConfig.get(JaggeryCoreConstants.JaggeryConfigParams.CONTEXT_PARAMS);
        if (arrContextParams != null) {
            for (Object contextParamObj : arrContextParams) {
                JSONObject contextParam = (JSONObject) contextParamObj;
                String name = (String) contextParam.get(JaggeryCoreConstants.JaggeryConfigParams.CONTEXT_PARAMS_NAME);
                String value = (String) contextParam.get(JaggeryCoreConstants.JaggeryConfigParams.CONTEXT_PARAMS_VALUE);
                ctx.addParameter(name, value);
            }
        }
    }
}
Also used : JSONObject(org.json.simple.JSONObject) JSONArray(org.json.simple.JSONArray) JSONObject(org.json.simple.JSONObject)

Example 19 with JSONArray

use of org.json.simple.JSONArray in project jaggery by wso2.

the class TomcatJaggeryWebappsDeployer method addListeners.

private static void addListeners(Context ctx, JSONObject jaggeryConfig) {
    if (jaggeryConfig != null) {
        JSONArray arrListeners = (JSONArray) jaggeryConfig.get(JaggeryCoreConstants.JaggeryConfigParams.LISTENERS);
        if (arrListeners != null) {
            for (Object listenerObj : arrListeners) {
                JSONObject listener = (JSONObject) listenerObj;
                String clazz = (String) listener.get(JaggeryCoreConstants.JaggeryConfigParams.LISTENERS_CLASS);
                ctx.addApplicationListener(clazz);
            }
        }
    }
}
Also used : JSONObject(org.json.simple.JSONObject) JSONArray(org.json.simple.JSONArray) JSONObject(org.json.simple.JSONObject)

Example 20 with JSONArray

use of org.json.simple.JSONArray in project jaggery by wso2.

the class JaggeryDeployerManager method addSecurityConstraints.

private static void addSecurityConstraints(Context context, JSONObject obj) {
    JSONArray arr = (JSONArray) obj.get(JaggeryCoreConstants.JaggeryConfigParams.SECURITY_CONSTRAINTS);
    if (arr != null) {
        for (Object anArr : arr) {
            JSONObject o = (JSONObject) anArr;
            SecurityConstraint securityConstraint = new SecurityConstraint();
            if (((JSONObject) o.get(JaggeryCoreConstants.JaggeryConfigParams.SECURITY_CONSTRAINT)).get(JaggeryCoreConstants.JaggeryConfigParams.WEB_RESOURCE_COLLECTION) != null) {
                JSONObject resCollection = (JSONObject) ((JSONObject) o.get(JaggeryCoreConstants.JaggeryConfigParams.SECURITY_CONSTRAINT)).get(JaggeryCoreConstants.JaggeryConfigParams.WEB_RESOURCE_COLLECTION);
                SecurityCollection secCollection = new SecurityCollection();
                secCollection.setName((String) resCollection.get(JaggeryCoreConstants.JaggeryConfigParams.WEB_RES_NAME));
                JSONArray arrPattern = (JSONArray) resCollection.get(JaggeryCoreConstants.JaggeryConfigParams.URL_PATTERNS);
                for (Object anArrPattern : arrPattern) {
                    secCollection.addPattern((String) anArrPattern);
                }
                JSONArray methods = (JSONArray) resCollection.get(JaggeryCoreConstants.JaggeryConfigParams.HTTP_METHODS);
                if (methods != null) {
                    for (Object method : methods) {
                        secCollection.addMethod((String) method);
                    }
                }
                securityConstraint.addCollection(secCollection);
            }
            if (((JSONObject) o.get(JaggeryCoreConstants.JaggeryConfigParams.SECURITY_CONSTRAINT)).get(JaggeryCoreConstants.JaggeryConfigParams.AUTH_ROLES) != null) {
                JSONArray roles = (JSONArray) ((JSONObject) o.get(JaggeryCoreConstants.JaggeryConfigParams.SECURITY_CONSTRAINT)).get(JaggeryCoreConstants.JaggeryConfigParams.AUTH_ROLES);
                for (Object role : roles) {
                    securityConstraint.addAuthRole((String) role);
                }
                securityConstraint.setAuthConstraint(true);
            }
            if (((JSONObject) o.get(JaggeryCoreConstants.JaggeryConfigParams.SECURITY_CONSTRAINT)).get(JaggeryCoreConstants.JaggeryConfigParams.USER_DATA_CONSTRAINT) != null) {
                JSONObject userDataConstraint = (JSONObject) ((JSONObject) o.get(JaggeryCoreConstants.JaggeryConfigParams.SECURITY_CONSTRAINT)).get(JaggeryCoreConstants.JaggeryConfigParams.USER_DATA_CONSTRAINT);
                String transportGuarantee = (String) userDataConstraint.get(JaggeryCoreConstants.JaggeryConfigParams.TRANSPORT_GUARANTEE);
                securityConstraint.setUserConstraint(transportGuarantee);
            }
            context.addConstraint(securityConstraint);
        }
    }
}
Also used : JSONObject(org.json.simple.JSONObject) JSONArray(org.json.simple.JSONArray) JSONObject(org.json.simple.JSONObject) ScriptableObject(org.mozilla.javascript.ScriptableObject) LogHostObject(org.jaggeryjs.hostobjects.log.LogHostObject)

Aggregations

JSONArray (org.json.simple.JSONArray)148 JSONObject (org.json.simple.JSONObject)129 JSONParser (org.json.simple.parser.JSONParser)61 HttpClient (org.apache.commons.httpclient.HttpClient)21 ParseException (org.json.simple.parser.ParseException)21 GetMethod (org.apache.commons.httpclient.methods.GetMethod)17 ArrayList (java.util.ArrayList)15 Test (org.junit.Test)15 File (java.io.File)11 IOException (java.io.IOException)11 MapLayer (au.org.emii.portal.menu.MapLayer)8 FileReader (java.io.FileReader)6 HashMap (java.util.HashMap)6 List (java.util.List)6 LegendObject (au.org.ala.legend.LegendObject)5 Point (com.vividsolutions.jts.geom.Point)5 PrintStream (java.io.PrintStream)5 Event (org.zkoss.zk.ui.event.Event)5 BuildResult (com.sonar.orchestrator.build.BuildResult)4 SonarScanner (com.sonar.orchestrator.build.SonarScanner)4