Examples of GDataRequest


Examples of com.google.gdata.client.Service.GDataRequest

    {
        try
        {
            if (photoLink != null)
            {
                GDataRequest request =
                    service.createLinkQueryRequest(photoLink);
                request.execute();
                InputStream in = request.getResponseStream();

                ByteArrayOutputStream out = new ByteArrayOutputStream();
                byte[] buffer = new byte[4096];

                for (int read = 0 ; (read = in.read(buffer)) != -1;
View Full Code Here

Examples of com.google.gdata.client.Service.GDataRequest

        //Axis2 client needs a configuration context
        ConfigurationContext configContext = null;

        String path = null;

        GDataRequest request = null;
        path = System.getProperty("user.dir");     

        try {

            //Create a configuration context. A configuration context contains information for a
            //axis2 environment. This is needed to create an axis2 client
            configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(
                    null, null);

            /**
             * Call to https://localhost:9443/services/AuthenticationAdmin?wsdl uses HTTPS protocol.
             * Therefore we to validate the server certificate. The server certificate is looked up in the
             * trust store. Following code sets what trust-store to look for and its JKs password.
             * Note : The trust store should have server's certificate.
             */
            System.setProperty("javax.net.ssl.trustStore",   path + File.separator +"wso2carbon.jks");
            System.setProperty("javax.net.ssl.trustStorePassword", "wso2carbon");

            /**
             * Here we are authenticating the given user name and password with IS.
             * https://localhost:9443/services/AuthenticationAdmin?wsdl
             */
            client = new AuthenticationServiceClient(IDENTITY_SERVER + "services/", configContext);

            /**
             * Actual authentication call. If authentication is successful,
             * User can register a consumer secret with IS.
             */
      if (client.authenticate(USER_NAME, PASSWORD, IDENTITY_SERVER_HOST_NAME)) {
          client.registerOAuthConsumer(CONSUMER_SECRET);
          System.out.println("User - " + USER_NAME + " successfully authenticated.");
      } else {
          System.out.println("Invalid credentials");
          return;
      }
            // We are using Google oauth API to call the service
            GoogleOAuthParameters oauthParameters = new GoogleOAuthParameters();

            // Setting user name as consumer key
            oauthParameters.setOAuthConsumerKey(USER_NAME);
            // Setting above assigned consumer secret
            oauthParameters.setOAuthConsumerSecret(CONSUMER_SECRET);

            // We will be using HMAC-SHA1 signature. Google API has a class to do that
            OAuthHmacSha1Signer signer = new OAuthHmacSha1Signer();

            // Create a Google service. The name of the current application given here
            // Names are only for reference purpose
            GoogleService service = new GoogleService("oauthclient", "sampleapp");
            service.setOAuthCredentials(oauthParameters, signer);

            /**
             * We will be calling test service's echoString method. As parameter we are sending "Hello World"
             * The parameter name is "in".
             */
            String param = "HelloWorld";
            String baseString = ESB_SERVER + "services/OAuthProxy/echoString" + "?xoauth_requestor_id="
                    + USER_NAME + "&in=" + param;

            /**
             * Invoking the request. And writing the response output.
             */
            URL feedUrl = new URL(baseString);
            request = service.createFeedRequest(feedUrl);
            request.execute();
           
            System.out.println(convertStreamToString(request.getResponseStream()));
           
        catch (AxisFault e) {
            e.printStackTrace();
        } catch (Exception e) {
            e.printStackTrace();
View Full Code Here

Examples of com.google.gdata.client.Service.GDataRequest

    } else {
      updatedEntry = String.format(UPDATED_ENTRY_ATOM_FORMAT, MODERATION_REJECTED);
    }

    try {
      GDataRequest request = service.createUpdateRequest(new URL(entryUrl));
      request.getRequestStream().write(updatedEntry.getBytes());
      request.execute();
    } catch (MalformedURLException e) {
      log.log(Level.WARNING, "", e);
    } catch (IOException e) {
      log.log(Level.WARNING, "", e);
    } catch (ServiceException e) {
View Full Code Here

Examples of com.google.gdata.client.Service.GDataRequest

    return null;
  }

  public String getCaptionTrack(String url) {
    try {
      GDataRequest request = service.createRequest(RequestType.QUERY, new URL(url),
          ContentType.TEXT_PLAIN);
      request.execute();

      BufferedReader reader = new BufferedReader(new InputStreamReader(request.getResponseStream(),
          "UTF-8"));
      StringBuilder builder = new StringBuilder();
      String line;

      while ((line = reader.readLine()) != null) {
View Full Code Here

Examples of com.google.gdata.client.Service.GDataRequest

   */
  public boolean updateCaptionTrack(String videoId, String captionTrack)
      throws MalformedURLException, IOException, ServiceException {
    String captionsUrl = String.format(CAPTION_FEED_URL_FORMAT, videoId);

    GDataRequest request = service.createInsertRequest(new URL(captionsUrl));
    request.getRequestStream().write(captionTrack.getBytes("UTF-8"));
    request.execute();

    BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(request
        .getResponseStream()));
    StringBuilder builder = new StringBuilder();
    String line = null;

    while ((line = bufferedReader.readLine()) != null) {
View Full Code Here

Examples of com.google.gdata.client.Service.GDataRequest

                sb.append(")");
               
                try {
                    String createQuery = sb.toString();
                   
                    GDataRequest createTableRequest = GDataExtension.createFusionTablesPostRequest(
                            service, RequestType.INSERT, createQuery);
                    createTableRequest.execute();
                   
                    List<List<String>> createTableResults =
                        GDataExtension.parseFusionTablesResults(createTableRequest);
                    if (createTableResults != null && createTableResults.size() == 2) {
                        tableId = createTableResults.get(1).get(0);
View Full Code Here

Examples of com.google.gdata.client.Service.GDataRequest

            }
        }
       
        void sendBatch() {
            try {
                GDataRequest createTableRequest = GDataExtension.createFusionTablesPostRequest(
                        service, RequestType.INSERT, sbBatch.toString());
                createTableRequest.execute();
            } catch (IOException e) {
                exceptions.add(e);
            } catch (ServiceException e) {
                exceptions.add(e);
            } finally {
View Full Code Here

Examples of com.google.gdata.client.Service.GDataRequest

        Pattern.compile("([^,\\r\\n\"]*|\"(([^\"]*\"\")*[^\"]*)\")(,|\\r?\\n)");
   
    static public List<List<String>> runFusionTablesSelect(GoogleService service, String selectQuery)
            throws IOException, ServiceException {
       
        GDataRequest request = createFusionTablesRequest(service, RequestType.QUERY, selectQuery);
        request.execute();
        return parseFusionTablesResults(request);
    }
View Full Code Here

Examples of com.google.gdata.client.Service.GDataRequest

   
    static public GDataRequest createFusionTablesPostRequest(
            GoogleService service, RequestType requestType, String query)
            throws IOException, ServiceException {
        URL url = new URL(FUSION_TABLES_SERVICE_URL);
        GDataRequest request = service.getRequestFactory().getRequest(
            requestType, url, new ContentType("application/x-www-form-urlencoded"));
       
        OutputStreamWriter writer =
            new OutputStreamWriter(request.getRequestStream());
        writer.append("sql=" + URLEncoder.encode(query, "UTF-8"));
        writer.flush();
        writer.close();
       
        return request;
View Full Code Here

Examples of com.google.gdata.client.Service.GDataRequest

    public QueryResults runQuery(String query) throws IOException, ServiceException {

      String lowercaseQuery = query.toLowerCase();
      String encodedQuery = URLEncoder.encode(query, "UTF-8");

      GDataRequest request;
      // If the query is a select, describe, or show query, run a GET request.
      if (lowercaseQuery.startsWith("select") ||
          lowercaseQuery.startsWith("describe") ||
          lowercaseQuery.startsWith("show")) {
        URL url = new URL(SERVICE_URL + "?sql=" + encodedQuery + "&encid=true");
        request = service.getRequestFactory().getRequest(RequestType.QUERY, url,
            ContentType.TEXT_PLAIN);
      } else {
        // Otherwise, run a POST request.
        URL url = new URL(SERVICE_URL + "?encid=true");
        request = service.getRequestFactory().getRequest(RequestType.INSERT, url,
            new ContentType("application/x-www-form-urlencoded"));
        OutputStreamWriter writer = new OutputStreamWriter(request.getRequestStream());
        writer.append("sql=" + encodedQuery);
        writer.flush();
      }

      request.execute();

      return getResults(request);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.