Package com.google.api.client.json.jackson

Examples of com.google.api.client.json.jackson.JacksonFactory


    return new UrlFetchTransport();
  }

  @Override
  protected JsonFactory newJsonFactoryInstance() {
    return new JacksonFactory();
  }
View Full Code Here


      throw ErrorHandler.wrongJsonFormat(jsonStr);
    }
  }

  public static <T> String parseDoubanObjToJSONStr(T obj) throws IOException {
    JsonHttpContent content = new JsonHttpContent(new JacksonFactory(), obj);
    ByteArrayOutputStream os = new ByteArrayOutputStream();
    content.writeTo(os);
    String result = new String(os.toByteArray());
    return result;
  }
View Full Code Here

  }
 
  private static void parseJson () {
    try {
      DoubanShuoAttachementObj att = generateAtt();
      JsonHttpContent content = new JsonHttpContent(new JacksonFactory(), att);
      ByteArrayOutputStream os = new ByteArrayOutputStream();
      content.writeTo(os);
      String result = new String(os.toByteArray());
      System.out.println("result ! : " + result);
      System.out.println("getdate : " + (String)content.getData());
View Full Code Here

   * @return a GoogleAuthorizationCodeFlow
   */
  protected GoogleAuthorizationCodeFlow getAuthorizationCodeFlow(boolean usePersistedCredentials)
      throws IOException {
    HttpTransport httpTransport = new NetHttpTransport();
    JsonFactory jsonFactory = new JacksonFactory();
    Collection<String> scopes = Arrays.asList(OAUTH2_SCOPE);
    GoogleClientSecrets clientSecrets = getClientSecrets();
    GoogleAuthorizationCodeFlow flow;
    if (usePersistedCredentials) {
      flow = new GoogleAuthorizationCodeFlow.Builder(
View Full Code Here

   * previously-provided credentials.
   */
  RemoteApiOptions useComputeEngineCredential() {
    try {
      HttpTransport transport = getOrCreateHttpTransportForOAuth();
      ComputeCredential credential = new ComputeCredential(transport, new JacksonFactory());
      credential.refreshToken();
      setOAuthCredential(credential);
    } catch (IOException|GeneralSecurityException e) {
      throw new RuntimeException("Failed to acquire Google Compute Engine credential.", e);
    }
View Full Code Here

  }

  private GoogleCredential.Builder getCredentialBuilder(
      String serviceAccount) throws GeneralSecurityException, IOException {
    HttpTransport transport = getOrCreateHttpTransportForOAuth();
    JacksonFactory jsonFactory = new JacksonFactory();
    return new GoogleCredential.Builder()
        .setTransport(transport)
        .setJsonFactory(jsonFactory)
        .setServiceAccountId(serviceAccount)
        .setServiceAccountScopes(OAUTH_SCOPES);
View Full Code Here

        headers.put("Content-Type", "application/json");
        transport.defaultHeaders = headers;
      
        //JsonCParser parser = new JsonCParser();
        JsonHttpParser parser = new JsonHttpParser();
        parser.jsonFactory = new JacksonFactory();
        transport.addParser(parser);

        // build the HTTP POST request and URL
        HttpRequest request = transport.buildPostRequest();
        request.setUrl(GOOGL_URL);
View Full Code Here

        return settings;
    }

    private Calendar getCalendar(final ApiKey apiKey) throws UpdateFailedException {
        HttpTransport httpTransport = new NetHttpTransport();
        JacksonFactory jsonFactory = new JacksonFactory();
        // Get all the attributes for this connector's oauth token from the stored attributes
        final String accessToken = guestService.getApiKeyAttribute(apiKey, "accessToken");
        final String refreshToken = guestService.getApiKeyAttribute(apiKey, "refreshToken");
        final String clientId = guestService.getApiKeyAttribute(apiKey, "google.client.id");
        final String clientSecret = guestService.getApiKeyAttribute(apiKey,"google.client.secret");
View Full Code Here

    @Override
    protected void fromFacet(final GoogleCalendarEventFacet facet, final TimeInterval timeInterval, final GuestSettings settings) throws OutsideTimeBoundariesException {
        try {
            this.allDayEvent = facet.allDayEvent;
            JacksonFactory jacksonFactory = new JacksonFactory();
            if (facet.attendeesStorage!=null) {
                this.attendees = new ArrayList<EventAttendee>();
                String[] attendees = facet.attendeesStorage.split("\\|");
                for (String attendee : attendees) {
                    final EventAttendee eventAttendee = jacksonFactory.fromString(attendee, EventAttendee.class);
                    eventAttendee.put("attendeeStatusClass", toCssClass(eventAttendee.getResponseStatus()));
                    this.attendees.add(eventAttendee);
                }
            }
            if (facet.creatorStorage!=null)
                creator = jacksonFactory.fromString(facet.creatorStorage, Event.Creator.class);
            if (facet.organizerStorage!=null)
                organizer = jacksonFactory.fromString(facet.organizerStorage, Event.Organizer.class);
            this.description = facet.description;
            this.summary = facet.summary;
            this.apiKeyId = facet.apiKeyId;
            this.calendarId = facet.calendarId;
            if (facet.location!=null)
View Full Code Here

    }

    private GoogleCredential getCredentials(ApiKey apiKey) throws UpdateFailedException{
        HttpTransport httpTransport = new NetHttpTransport();
        JacksonFactory jsonFactory = new JacksonFactory();
        // Get all the attributes for this connector's oauth token from the stored attributes
        String accessToken = guestService.getApiKeyAttribute(apiKey, "accessToken");
        final String refreshToken = guestService.getApiKeyAttribute(apiKey, "refreshToken");
        final String clientId = guestService.getApiKeyAttribute(apiKey, "google.client.id");
        final String clientSecret = guestService.getApiKeyAttribute(apiKey,"google.client.secret");
View Full Code Here

TOP

Related Classes of com.google.api.client.json.jackson.JacksonFactory

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.