コード例 #1
0
    /**
     * Retrieves the first request in the queue and builds the full REST URI
     * given the properties of this request before creating a new HTTP request,
     * signing it, and sending it to the container.
     *
     * @param  client OpenSocialClient object with REST_BASE_URI property set
     * @return Object encapsulating the data requested from the container
     * @throws OpenSocialRequestException
     * @throws JSONException
     * @throws OAuthException
     * @throws IOException
     * @throws URISyntaxException
     */
    private OpenSocialResponse submitRest(OpenSocialClient client)
    {
        String restBaseUri =
            client.getProperty(OpenSocialClient.Properties.REST_BASE_URI);

        OpenSocialRequest r = this.requests[0];

        OpenSocialUrl requestUrl = new OpenSocialUrl(restBaseUri);

        requestUrl.addPathComponent(r.getRestPathComponent());
        if (r.getParameter("userId") != null)
        {
            requestUrl.addPathComponent(r.getParameter("userId"));
        }
        if (r.getParameter("groupId") != null)
        {
            requestUrl.addPathComponent(r.getParameter("groupId"));
        }
        if (r.getParameter("appId") != null)
        {
            requestUrl.addPathComponent(r.getParameter("appId"));
        }

        OpenSocialHttpRequest request = new OpenSocialHttpRequest(requestUrl);

        OpenSocialRequestSigner.signRequest(request, client);

        String responseString = getHttpResponse(request);

        return(OpenSocialJsonParser.getResponse(responseString, r.getId()));
    }
コード例 #2
0
    /**
     * Collects all of the queued requests and encodes them into a single JSON
     * string before creating a new HTTP request, attaching this string to the
     * request body, signing it, and sending it to the container.
     *
     * @param  client OpenSocialClient object with RPC_ENDPOINT property set
     * @return Object encapsulating the data requested from the container
     * @throws OpenSocialRequestException
     * @throws JSONException
     * @throws OAuthException
     * @throws IOException
     * @throws URISyntaxException
     */
    private OpenSocialResponse submitRpc(OpenSocialClient client)
    {
        String rpcEndpoint =
            client.getProperty(OpenSocialClient.Properties.RPC_ENDPOINT);

        JsonArray requestArray = new JsonArray();

        foreach (OpenSocialRequest r in this.requests)
        {
            requestArray.Put(JsonConvert.Import(r.getJsonEncoding()));
        }

        OpenSocialUrl requestUrl = new OpenSocialUrl(rpcEndpoint);

        OpenSocialHttpRequest request = new OpenSocialHttpRequest(requestUrl);

        request.setPostBody(requestArray.ToString());

        OpenSocialRequestSigner.signRequest(request, client);

        String responseString = getHttpResponse(request);

        return(OpenSocialJsonParser.getResponse(responseString));
    }
コード例 #3
0
    /**
     * Retrieves and parses the JSON-encoded response item with the passed ID and
     * returns the parsed item as a List of OpenSocialPerson objects.
     *
     * @param  id ID of the response item to parse
     * @throws OpenSocialRequestException
     * @throws JSONException
     * @throws IllegalAccessException
     * @throws InstantiationException
     */
    public List <OpenSocialPerson> getItemAsPersonCollection(String id)
    {
        String item = this.items[id];

        return(OpenSocialJsonParser.parseAsPersonCollection(item));
    }
コード例 #4
0
    /**
     * Retrieves and parses the JSON-encoded response item with the passed ID and
     * returns the parsed item as an OpenSocialAppData object.
     *
     * @param  id ID of the response item to parse
     * @throws OpenSocialRequestException
     * @throws JSONException
     * @throws InstantiationException
     * @throws IllegalAccessException
     */
    public OpenSocialAppData getItemAsAppData(String id)
    {
        String item = this.items[id];

        return(OpenSocialJsonParser.parseAsAppData(item));
    }
コード例 #5
0
    /**
     * Retrieves and parses the JSON-encoded response item with the passed ID and
     * returns the parsed item as an OpenSocialPerson object.
     *
     * @param  id ID of the response item to parse
     * @throws OpenSocialRequestException
     * @throws JSONException
     * @throws IllegalAccessException
     * @throws InstantiationException
     */
    public OpenSocialPerson getItemAsPerson(String id)
    {
        String item = this.items[id];

        return(OpenSocialJsonParser.parseAsPerson(item));
    }