Package org.apache.sling.commons.json

Examples of org.apache.sling.commons.json.JSONArray


        String getUrl = HTTP_BASE_URL + "/system/userManager/group/" + testGroupId + ".json";
    assertAuthenticatedHttpStatus(creds, getUrl, HttpServletResponse.SC_OK, null); //make sure the profile request returns some data
        String json = getAuthenticatedContent(creds, getUrl, CONTENT_TYPE_JSON, null, HttpServletResponse.SC_OK);
        assertNotNull(json);
        JSONObject jsonObj = new JSONObject(json);
        JSONArray members = jsonObj.getJSONArray("members");
        return members;
    }
View Full Code Here


    assertEquals(0, aceObject.getInt("order"));

    String principalString = aceObject.optString("principal");
    assertEquals(testUserId, principalString);
   
    JSONArray grantedArray = aceObject.optJSONArray("granted");
    assertNotNull(grantedArray);
    assertEquals("jcr:read", grantedArray.getString(0));

    JSONArray deniedArray = aceObject.optJSONArray("denied");
    assertNotNull(deniedArray);
    assertEquals("jcr:write", deniedArray.getString(0));

    if (addGroupAce) {
      aceObject = jsonObject.optJSONObject(testGroupId);
      assertNotNull(aceObject);
     
View Full Code Here

                "/a/b/c",
                "/d/e/f",
                "/g/h/i"
        };

        JSONArray actualArray = json.getJSONArray("filterSets");
        for(int i = 0; i < actualArray.length(); i++) {
            JSONObject tmp = actualArray.getJSONObject(i);
            assertTrue(ArrayUtils.contains(expectedFilterSets, tmp.get("rootPath")));
        }

        assertEquals(expectedFilterSets.length, actualArray.length());
    }
View Full Code Here

                "/a/b/c",
                "/d/e/f",
                "/g/h/i"
        };

        JSONArray actualArray = json.getJSONArray("filterSets");
        for(int i = 0; i < actualArray.length(); i++) {
            JSONObject tmp = actualArray.getJSONObject(i);
            assertTrue(ArrayUtils.contains(expectedFilterSets, tmp.get("rootPath")));
        }

        assertEquals(expectedFilterSets.length, actualArray.length());
    }
View Full Code Here

                "/a/b/c",
                "/d/e/f",
                "/g/h/i"
        };

        JSONArray actualArray = json.getJSONArray("filterSets");
        for(int i = 0; i < actualArray.length(); i++) {
            JSONObject tmp = actualArray.getJSONObject(i);
            assertTrue(ArrayUtils.contains(expectedFilterSets, tmp.get("rootPath")));
        }

        assertEquals(expectedFilterSets.length, actualArray.length());
    }
View Full Code Here

        for (Map.Entry<String, RequestParameter[]> entry : map.entrySet()) {
            String key = entry.getKey();
            RequestParameter[] params = entry.getValue();
            if (params != null) {
                if (params.length > 1) {
                    JSONArray arr = new JSONArray();
                    for (int i = 0; i < params.length; i++) {
                        arr.put(params[i].getString());
                    }
                    widget.put(key, arr);
                } else if (params.length == 1) {
                    widget.put(key, params[0].getString());
                }
View Full Code Here

    protected void doGet(SlingHttpServletRequest request, SlingHttpServletResponse response) throws ServletException,
            IOException {
        XSSAPI xssAPI = request.adaptTo(XSSAPI.class);
        try {
            JSONObject result = new JSONObject();
            JSONArray list = new JSONArray();
            result.put("list", list);

            ServiceReference[] services = tracker.getServiceReferences();
            if (services != null) {
                for (ServiceReference service : services) {
                    String displayName = PropertiesUtil.toString(service.getProperty("displayName"), null);
                    String[] schemes = PropertiesUtil.toStringArray(service.getProperty(Importer.SCHEME_PROPERTY));
                    if (displayName != null && schemes != null) {
                        for (String scheme : schemes) {
                            JSONObject obj = new JSONObject();
                            obj.put("qtip", "");
                            obj.put("text", displayName);
                            obj.put("text_xss", xssAPI.encodeForJSString(displayName));
                            obj.put("value", scheme);
                            list.put(obj);
                        }
                    }
                }
            }
View Full Code Here

        for (Map.Entry<String, RequestParameter[]> entry : map.entrySet()) {
            String key = entry.getKey();
            RequestParameter[] params = entry.getValue();
            if (params != null) {
                if (params.length > 1 || EXTERNAL_STYLESHEETS_PROPERTY.equals(key)) {
                    JSONArray arr = new JSONArray();
                    for (int i = 0; i < params.length; i++) {
                        arr.put(params[i].getString());
                    }
                    widget.put(key, arr);
                } else if (params.length == 1) {
                    widget.put(key, params[0].getString());
                }
View Full Code Here

        MockSlingHttpServletResponse response = new MockSlingHttpServletResponse();

        servlet.doGet(request, response);

        assertEquals("application/json", response.getContentType());
        JSONArray array = new JSONArray(response.getOutput().toString());
        assertEquals(4, array.length());
    }
View Full Code Here

                                replicationResult.getPath(),
                                replicationResult.getStatus());
                    }
                }

                JSONArray arr = convertResponseToJson(response);
                obj = new JSONObject();
                obj.put("result", arr);

            } else {
                log.debug("Did not attempt to replicate version due to issue with input params");
View Full Code Here

TOP

Related Classes of org.apache.sling.commons.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.