/**
     * 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()));
    }
    /**
     * Creates and returns a new OpenSocialRequest object for retrieving the
     * person or group of people selected by the arguments.
     *
     * @param  userId OpenSocial ID of the request's target
     * @param  groupId "@self" to fetch the user's profile details or "@friends"
     *         to fetch the user's friend list
     */
    private static OpenSocialRequest newFetchPeopleRequest(
        String userId, String groupId)
    {
        OpenSocialRequest r = new OpenSocialRequest("people", "people.get");

        r.addParameter("groupId", groupId);
        r.addParameter("userId", userId);

        return(r);
    }
    /**
     * Creates and returns a new OpenSocialRequest object for retrieving the
     * persistent App Data for the person or group of people selected by the
     * arguments for the specified application.
     *
     * @param  userId OpenSocial ID of the request's target
     * @param  groupId "@self" to fetch the user's App Data or "@friends" to
     *         fetch App Data for the user's friends
     * @param  appId The ID of the application to fetch user App Data for
     *         or "@app" for the current application
     */
    public static OpenSocialRequest newFetchPersonAppDataRequest(
        String userId, String groupId, String appId)
    {
        OpenSocialRequest r = new OpenSocialRequest("appdata", "appdata.get");

        r.addParameter("groupId", groupId);
        r.addParameter("userId", userId);
        r.addParameter("appId", appId);

        return(r);
    }
    /**
     * Creates and submits a new request to retrieve the person or group of
     * people selected by the arguments and returns the response from the
     * container as an OpenSocialResponse object.
     *
     * @param  userId OpenSocial ID of the request's target
     * @param  groupId "@self" to fetch the user's profile details or "@friends"
     *         to fetch the user's friend list
     * @throws OpenSocialRequestException if there are any runtime issues with
     *         establishing a RESTful or JSON-RPC connection or parsing the
     *         response that the container returns
     * @throws JSONException
     * @throws OAuthException
     * @throws IOException
     * @throws URISyntaxException
     */
    private OpenSocialResponse fetchPeople(String userId, String groupId)
    {
        if (userId.Equals("") || groupId.Equals(""))
        {
            throw new OpenSocialRequestException("Invalid request parameters");
        }

        OpenSocialRequest r =
            OpenSocialClient.newFetchPeopleRequest(userId, groupId);

        OpenSocialBatch batch = new OpenSocialBatch();

        batch.addRequest(r, "people");

        return(batch.send(this));
    }
Exemple #5
0
  /**
   * Creates and returns a new OpenSocialRequest object for retrieving the
   * persistent App Data for the person or group of people selected by the
   * arguments for the specified application.
   * 
   * @param  userId OpenSocial ID of the request's target
   * @param  groupId "@self" to fetch the user's App Data or "@friends" to
   *         fetch App Data for the user's friends
   * @param  appId The ID of the application to fetch user App Data for
   *         or "@app" for the current application
   */
  public static OpenSocialRequest newFetchPersonAppDataRequest(
      String userId, String groupId, String appId) {
    
    OpenSocialRequest r = new OpenSocialRequest("appdata", "appdata.get");
    r.addParameter("groupId", groupId);
    r.addParameter("userId", userId);
    r.addParameter("appId", appId);

    return r;
  }
Exemple #6
0
 /**
  * Creates and returns a new OpenSocialRequest object for retrieving the
  * person or group of people selected by the arguments.
  * 
  * @param  userId OpenSocial ID of the request's target
  * @param  groupId "@self" to fetch the user's profile details or "@friends"
  *         to fetch the user's friend list
  */
 private static OpenSocialRequest newFetchPeopleRequest(
     String userId, String groupId) {
   
   OpenSocialRequest r = new OpenSocialRequest("people", "people.get");
   r.addParameter("groupId", groupId);
   r.addParameter("userId", userId);
   
   return r;
 }
 /**
  * Sets the id property of the passed request and adds it to the internal
  * collection.
  *
  * @param request OpenSocialRequest object to Add to internal collection
  * @param id Request label, used to extract data from OpenSocialResponse
  *           object returned
  */
 public void addRequest(OpenSocialRequest request, String id)
 {
     request.setId(id);
     this.requests.Add(request);
 }
Exemple #8
0
 /**
  * Sets the id property of the passed request and adds it to the internal
  * collection.
  * 
  * @param request OpenSocialRequest object to Add to internal collection
  * @param id Request label, used to extract data from OpenSocialResponse
  *           object returned
  */
 public void addRequest(OpenSocialRequest request, String id) {
   request.setId(id);  
   this.requests.Add(request);
 }