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;
}
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);
}
}
}
}
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);
}
}
}
}
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);
}
}
}
}
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);
}
}
}
Aggregations