Package api.http

Examples of api.http.HttpRequest


    } catch (Exception ex){
    }
  }

  public void delete() throws IOException{
    HttpRequest httpRequest = new HttpRequest(this.editUrl);
    if (this.picasaPhoto.getPicasaAlbum().getPicasaWeb().getGoogleapi() != null){
      KeyValuePair pair = this.picasaPhoto.getPicasaAlbum().getPicasaWeb().getGoogleapi().toAuthHeader();
      httpRequest.addHeader(pair.key, pair.value);
    }
    httpRequest.setMethod(HttpRequest.METHOD_DELETE);
    httpRequest.setContentType("application/atom+xml");
    String response = httpRequest.send();
    this.tag = null;
    this.editUrl = null;
    this.lastModified = null;
  }
View Full Code Here


   * @param cover the cover of Picasa Album.
   * @throws IOException the url is not exist or something wrong of the server
   * of target url.
   */
  public void update(String title, String description, String access, Date lastModified, Boolean canComment, String position, String location, URL cover) throws IOException{
    HttpRequest httpRequest = new HttpRequest(this.editUrl);
    if (this.getPicasaWeb().getGoogleapi() != null){
      KeyValuePair pair = this.getPicasaWeb().getGoogleapi().toAuthHeader();
      httpRequest.addHeader(pair.key, pair.value);
    }
    if (title != null){
      this.title = title;
    }
    if (description != null){
      this.description = description;
    }
    if (access != null){
      this.access = access;
    }
    if (lastModified != null){
      this.lastModified = lastModified;
    }
    if (canComment != null){
      this.canComment = canComment;
    }
    if (position != null){
      this.position = position;
    }
    if (location != null){
      this.location = location;
    }
    if (cover != null){
      this.cover = cover;
    }
    String data = PicasaAlbum.createAlbumXML(this.title, this.description, this.access, this.lastModified, this.canComment, this.position, this.location, this.cover, this.albumId);
    httpRequest.setData(data);
    httpRequest.setMethod(HttpRequest.METHOD_PUT);
    httpRequest.setContentType("application/atom+xml");
    String response = httpRequest.send();
  }
View Full Code Here

   *
   * @throws IOException the url is not exist or something wrong of the server
   * of target url.
   */
  public void delete() throws IOException{
    HttpRequest httpRequest = new HttpRequest(this.editUrl);
    if (this.getPicasaWeb().getGoogleapi() != null){
      KeyValuePair pair = this.getPicasaWeb().getGoogleapi().toAuthHeader();
      httpRequest.addHeader(pair.key, pair.value);
    }
    httpRequest.setMethod(HttpRequest.METHOD_DELETE);
    httpRequest.setContentType("application/atom+xml");
    String response = httpRequest.send();
    this.albumId = null;
    this.title = null;
    this.description = null;
    this.access = null;
    this.lastModified = null;
View Full Code Here

    URL url = new URL(this.entryUrl.toString() + "/photoid/" + id);
    return this.getPhoto(url);
  }

  private PicasaPhoto getPhoto(URL url) throws IOException, ParserConfigurationException, SAXException{
    HttpRequest httpRequest = new HttpRequest(url);
    if (this.picasaWeb.getGoogleapi() != null){
      KeyValuePair pair = this.picasaWeb.getGoogleapi().toAuthHeader();
      httpRequest.addHeader(pair.key, pair.value);
    }
    String response = httpRequest.send();
    Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new InputSource(new StringReader(response)));
    return new PicasaPhoto(this, document.getDocumentElement());
  }
View Full Code Here

   * of target url.
   * @throws ParserConfigurationException the response is not a parsable XML.
   * @throws SAXException the response is not a parsable XML.
   */
  public PicasaPhoto[] listPhotos() throws IOException, ParserConfigurationException, SAXException{
    HttpRequest httpRequest = new HttpRequest(this.feedUrl);
    if (this.picasaWeb.getGoogleapi() != null){
      KeyValuePair pair = this.picasaWeb.getGoogleapi().toAuthHeader();
      httpRequest.addHeader(pair.key, pair.value);
    }
    String response = httpRequest.send();
    Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new InputSource(new StringReader(response)));
    List<PicasaPhoto> picasaPhotos = new ArrayList<PicasaPhoto>();
    NodeList entries = document.getElementsByTagName("entry");
    for (int i = 0; i < entries.getLength(); i++){
      Element entry = (Element)entries.item(i);
View Full Code Here

    URL url = new URL(this.entryUrl.toString() + "/tag/" + tag);
    return this.getTag(url);
  }

  private PicasaTag getTag(URL url) throws IOException, ParserConfigurationException, SAXException{
    HttpRequest httpRequest = new HttpRequest(url);
    if (this.picasaAlbum.getPicasaWeb().getGoogleapi() != null){
      KeyValuePair pair = this.picasaAlbum.getPicasaWeb().getGoogleapi().toAuthHeader();
      httpRequest.addHeader(pair.key, pair.value);
    }
    String response = httpRequest.send();
    Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new InputSource(new StringReader(response)));
    return new PicasaTag(this, document.getDocumentElement());
  }
View Full Code Here

   * @throws SAXException the response is not a parsable XML.
   */
  public PicasaTag[] listTags() throws IOException, ParserConfigurationException, SAXException{
    String path = this.feedUrl.getQuery();
    path = this.feedUrl.toString() + ((path == null || path.length() == 0) ? "?" : "&") + "kind=tag";
    HttpRequest httpRequest = new HttpRequest(new URL(path));
    if (this.picasaAlbum.getPicasaWeb().getGoogleapi() != null){
      KeyValuePair pair = this.picasaAlbum.getPicasaWeb().getGoogleapi().toAuthHeader();
      httpRequest.addHeader(pair.key, pair.value);
    }
    String response = httpRequest.send();
    Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new InputSource(new StringReader(response)));
    List<PicasaTag> picasaTags = new ArrayList<PicasaTag>();
    NodeList entries = document.getElementsByTagName("entry");
    for (int i = 0; i < entries.getLength(); i++){
      Element entry = (Element)entries.item(i);
View Full Code Here

   * of target url.
   * @throws ParserConfigurationException the response is not a parsable XML.
   * @throws SAXException the response is not a parsable XML.
   */
  public PicasaTag addTag(String tag) throws IOException, ParserConfigurationException, SAXException{
    HttpRequest httpRequest = new HttpRequest(this.feedUrl);
    if (this.picasaAlbum.getPicasaWeb().getGoogleapi() != null){
      KeyValuePair pair = this.picasaAlbum.getPicasaWeb().getGoogleapi().toAuthHeader();
      httpRequest.addHeader(pair.key, pair.value);
    }
    String data = PicasaTag.createTagXML(tag);
    httpRequest.setData(data);
    httpRequest.setMethod(HttpRequest.METHOD_POST);
    httpRequest.setContentType("application/atom+xml");
    String response = httpRequest.send();
    Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new InputSource(new StringReader(response)));
    return new PicasaTag(this, document.getDocumentElement());
  }
View Full Code Here

    } catch (Exception ex){
    }
  }

  public void delete() throws IOException{
    HttpRequest httpRequest = new HttpRequest(this.editUrl);
    if (this.picasaPhoto.getPicasaAlbum().getPicasaWeb().getGoogleapi() != null){
      KeyValuePair pair = this.picasaPhoto.getPicasaAlbum().getPicasaWeb().getGoogleapi().toAuthHeader();
      httpRequest.addHeader(pair.key, pair.value);
    }
    httpRequest.setMethod(HttpRequest.METHOD_DELETE);
    httpRequest.setContentType("application/atom+xml");
    String response = httpRequest.send();
    this.comment = null;
    this.commentId = null;
    this.editUrl = null;
    this.lastModified = null;
  }
View Full Code Here

TOP

Related Classes of api.http.HttpRequest

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.