Package com.google.api.gbase.client

Examples of com.google.api.gbase.client.GoogleBaseService


   * @throws EPAuthenticationException
   */
  private GoogleBaseService getBaseService()
      throws EPAuthenticationException {
    if (this.baseService == null) {
      GoogleBaseService baseService = new GoogleBaseService(APP_IDENTITY,"none");
      try {
        baseService.setUserCredentials(baseUsername, basePassword);
      } catch (com.google.gdata.util.AuthenticationException authEx) {
        throw new EPAuthenticationException("Bad calendar credentials");
      }
      this.baseService = baseService;
      return baseService;
View Full Code Here


   * @throws IOException
   * @throws ServiceException
   */
  private void publishEventToBase(Event event)
      throws EPAuthenticationException, IOException, ServiceException {
    GoogleBaseService baseService = getBaseService();
    GoogleBaseEntry entry = null;
    if (event.getBaseUrl() != null) {
      // updating base entry
      entry = baseService.getEntry(event.getBaseUrl(),
          GoogleBaseEntry.class);
      entry = new GoogleBaseEntry();
    } else {
      // publishing new entry
      entry = new GoogleBaseEntry();  
    }

    // prepare an 'events and activities' item for publishing
    GoogleBaseAttributesExtension gbaseAttributes =
      entry.getGoogleBaseAttributes();
    entry.setTitle(new PlainTextConstruct(event.getTitle()));
    entry.setContent(new PlainTextConstruct(event.getDescription()));
    gbaseAttributes.setItemType("events and activities");

    // this sample currently only demonstrates publishing all-day events
    // an event in Google Base must have a start-time and end-time, so
    // this simulates that by adding 1 day to the end-date specified, if the
    // start and end times are identical
    DateTime startDateTime = new DateTime(event.getStartDate());
    startDateTime.setDateOnly(true);

    DateTime endDateTime = null;

    if (event.getStartDate().equals(event.getEndDate())) {
      Calendar endDateCal = new GregorianCalendar();
      endDateCal.setTime(event.getEndDate());
      endDateCal.add(Calendar.DATE, 1);
      endDateTime = new DateTime(endDateCal.getTime());
    } else {
      endDateTime = new DateTime(event.getEndDate());
    }
    endDateTime.setDateOnly(true);
 
    gbaseAttributes.addDateTimeRangeAttribute("event date range",
        new DateTimeRange(startDateTime, endDateTime));
   
    gbaseAttributes.addTextAttribute("event performer", "Google mashup test");
    gbaseAttributes.addUrlAttribute("performer url", "http://code.google.com/apis/gdata.html");
   
    if (event.getBaseUrl() != null) {
      // updating event
      baseService.update(event.getBaseUrl(), entry);
    } else {
      // insert event
      GoogleBaseEntry resultEntry = baseService.insert(
          FeedURLFactory.getDefault().getItemsFeedURL(),
          entry);
      updateSsEventEditUrl(event.getSsEditUrl(),
          null,
          resultEntry.getEditLink().getHref() );
View Full Code Here

    }
    servletContext.setAttribute(FEED_URL_FACTORY_ATTRIBUTE, urlFactory);
   
    String key = servletContext.getInitParameter(RecipeUtil.DEVELOPER_KEY_PARAMETER);

    GoogleBaseService service = new GoogleBaseService(applicationName, key);
    mostUsedValues = new MostUsedValues(service,
                                        urlFactory,
                                        RecipeUtil.RECIPE_ITEMTYPE_QUERY);
    initMostUsedValues(mostUsedValues, servletContext);
    RecipeUtil.setMostUsedValues(servletContext, mostUsedValues);
View Full Code Here

   * @param servletContext
   * @return a GoogleBaseService object
   */
  public static GoogleBaseService getGoogleBaseService(HttpServletRequest req,
          ServletContext servletContext) {
    GoogleBaseService service;
    service = (GoogleBaseService) req.getAttribute(
        AuthenticationFilter.SERVICE_ATTRIBUTE);
    if (service == null) {
      service = new GoogleBaseService(
          servletContext.getInitParameter(APPLICATION_NAME_PARAMETER),
          servletContext.getInitParameter(DEVELOPER_KEY_PARAMETER));
      req.setAttribute(AuthenticationFilter.SERVICE_ATTRIBUTE, service);
    }
    return service;
View Full Code Here

  @Override
  protected void doGet(HttpServletRequest request,
                       HttpServletResponse response)
      throws ServletException, IOException {
    // This is a public page, so we use a simple, nonauthenticated service
    GoogleBaseService service = RecipeUtil.getGoogleBaseService(request,
        this.getServletContext());
    String id = request.getParameter(RecipeUtil.ID_PARAMETER);
    recipeDisplay(request, response, service, id);
  }
View Full Code Here

      redirectToAuthSub(httpRequest, httpResponse);
      return;
    }

    // Create a service that authenticates using the session token
    GoogleBaseService service = new GoogleBaseService(
        applicationName, key, authsubProtocol, authsubHostname);
    service.setAuthSubToken(sessionToken);

    // Make the service available to the servlet
    httpRequest.setAttribute(SERVICE_ATTRIBUTE, service);
   
    // Execute the servlet
View Full Code Here

   * @throws com.google.gdata.util.AuthenticationException
   *  if authentication failed
   */
  protected GoogleBaseService createService()
      throws AuthenticationException {
    GoogleBaseService service =
        new GoogleBaseService("Google.-CustomerTool-1.0",
                              key,
                              authenticationProtocol,
                              authenticationServer);                                                     
    service.setUserCredentials(username, password);
    return service;
  }
View Full Code Here

   */
  @Override
  protected void doGet(HttpServletRequest request,
                       HttpServletResponse response)
      throws ServletException, IOException {
    GoogleBaseService service = RecipeUtil.getGoogleBaseService(request,
        this.getServletContext());
    RecipeSearch recipeSearch;
    try {
      if (request.getParameter("query") == null) {
        recipeSearch = new RecipeSearch(service, urlFactory, ownItems);
View Full Code Here

    }

    // service.query does a GET on the url above and parses the result,
    // which is an ATOM feed with some extensions (called the Google Base
    // data API items feed).
    service = new GoogleBaseService(applicationName);
    if (argsIndex > 0) {
      String[] newargs = new String[args.length - argsIndex];
      System.arraycopy(args, argsIndex, newargs, 0, newargs.length);
      args = newargs;
    }
View Full Code Here

  /** Inserts or updates the submitted recipe and redirects to recipeList. */
  @Override
  protected void doPost(HttpServletRequest request,
                        HttpServletResponse response)
      throws ServletException, IOException {
    GoogleBaseService service = (GoogleBaseService) request.getAttribute(
        AuthenticationFilter.SERVICE_ATTRIBUTE);
    Recipe recipe = getPostedRecipe(request);
    if (!recipe.isComplete()) {
      String message = "<div class='errormessage'>Please fill out " +
                       "all the mandatory fields.</div>";
View Full Code Here

TOP

Related Classes of com.google.api.gbase.client.GoogleBaseService

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.