Examples of PhotoList


Examples of com.aetrion.flickr.photos.PhotoList

     * @throws IOException
     * @throws SAXException
     */
    public PhotoList getList(String userId, int perPage, int page, Set extras) throws IOException,
            SAXException, FlickrException {
        PhotoList photos = new PhotoList();

        List parameters = new ArrayList();
        parameters.add(new Parameter("method", METHOD_GET_LIST));
        parameters.add(new Parameter("api_key", apiKey));

        if (userId != null) {
            parameters.add(new Parameter("user_id", userId));
        }
        if (extras != null) {
            parameters.add(new Parameter("extras", StringUtilities.join(extras, ",")));
        }
        if (perPage > 0) {
            parameters.add(new Parameter("per_page", new Integer(perPage)));
        }
        if (page > 0) {
            parameters.add(new Parameter("page", new Integer(page)));
        }
        parameters.add(
            new Parameter(
                "api_sig",
                AuthUtilities.getSignature(sharedSecret, parameters)
            )
        );

        Response response = transportAPI.get(transportAPI.getPath(), parameters);
        if (response.isError()) {
            throw new FlickrException(response.getErrorCode(), response.getErrorMessage());
        }

        Element photosElement = response.getPayload();
        photos.setPage(photosElement.getAttribute("page"));
    photos.setPages(photosElement.getAttribute("pages"));
    photos.setPerPage(photosElement.getAttribute("perpage"));
    photos.setTotal(photosElement.getAttribute("total"));
        NodeList photoNodes = photosElement.getElementsByTagName("photo");
        for (int i = 0; i < photoNodes.getLength(); i++) {
            Element photoElement = (Element) photoNodes.item(i);
            photos.add(PhotoUtils.createPhoto(photoElement));
        }
        return photos;
    }
View Full Code Here

Examples of com.aetrion.flickr.photos.PhotoList

     * @throws SAXException
     * @throws FlickrException
     */
    public PhotoList getPhotos(String groupId, String[] tags, Set extras, int perPage, int page)
      throws IOException, SAXException, FlickrException {
        PhotoList photos = new PhotoList();

        List parameters = new ArrayList();
        parameters.add(new Parameter("method", METHOD_GET_PHOTOS));
        parameters.add(new Parameter("api_key", apiKey));

        parameters.add(new Parameter("group_id", groupId));
        if (tags != null) {
            parameters.add(new Parameter("tags", StringUtilities.join(tags, " ")));
        }
        if (perPage > 0) {
            parameters.add(new Parameter("per_page", new Integer(perPage)));
        }
        if (page > 0) {
            parameters.add(new Parameter("page", new Integer(page)));
        }

        if (extras != null) {
            StringBuffer sb = new StringBuffer();
            Iterator it = extras.iterator();
            for (int i = 0; it.hasNext(); i++) {
                if (i > 0) {
                    sb.append(",");
                }
                sb.append(it.next());
            }
            parameters.add(new Parameter(Extras.KEY_EXTRAS, sb.toString()));
        }
        parameters.add(
            new Parameter(
                "api_sig",
                AuthUtilities.getSignature(sharedSecret, parameters)
            )
        );

        Response response = transport.get(transport.getPath(), parameters);
        if (response.isError()) {
            throw new FlickrException(response.getErrorCode(), response.getErrorMessage());
        }
        Element photosElement = response.getPayload();
        photos.setPage(photosElement.getAttribute("page"));
        photos.setPages(photosElement.getAttribute("pages"));
        photos.setPerPage(photosElement.getAttribute("perpage"));
        photos.setTotal(photosElement.getAttribute("total"));

        NodeList photoNodes = photosElement.getElementsByTagName("photo");
        for (int i = 0; i < photoNodes.getLength(); i++) {
            Element photoElement = (Element) photoNodes.item(i);
            photos.add(PhotoUtils.createPhoto(photoElement));
        }

        return photos;
    }
View Full Code Here

Examples of com.aetrion.flickr.photos.PhotoList

     * @throws FlickrException
     * @see com.aetrion.flickr.photos.Extras
     */
    public PhotoList getPublicList(String userId, int perPage, int page, Set extras)
            throws IOException, SAXException, FlickrException {
        PhotoList photos = new PhotoList();

        List parameters = new ArrayList();
        parameters.add(new Parameter("method", METHOD_GET_PUBLIC_LIST));
        parameters.add(new Parameter("api_key", apiKey));

        parameters.add(new Parameter("user_id", userId));

        if (extras != null) {
            parameters.add(new Parameter("extras", StringUtilities.join(extras, ",")));
        }
        if (perPage > 0) {
            parameters.add(new Parameter("per_page", new Integer(perPage)));
        }
        if (page > 0) {
            parameters.add(new Parameter("page", new Integer(page)));
        }
        parameters.add(
            new Parameter(
                "api_sig",
                AuthUtilities.getSignature(sharedSecret, parameters)
            )
        );

        Response response = transportAPI.get(transportAPI.getPath(), parameters);
        if (response.isError()) {
            throw new FlickrException(response.getErrorCode(), response.getErrorMessage());
        }

        Element photosElement = response.getPayload();
        photos.setPage(photosElement.getAttribute("page"));
    photos.setPages(photosElement.getAttribute("pages"));
    photos.setPerPage(photosElement.getAttribute("perpage"));
    photos.setTotal(photosElement.getAttribute("total"));
        NodeList photoNodes = photosElement.getElementsByTagName("photo");
        for (int i = 0; i < photoNodes.getLength(); i++) {
            Element photoElement = (Element) photoNodes.item(i);
            photos.add(PhotoUtils.createPhoto(photoElement));
        }
        return photos;
    }
View Full Code Here

Examples of com.aetrion.flickr.photos.PhotoList

     * @throws SAXException
     * @throws FlickrException
     */
    public PhotoList getPublicPhotos(String userId, Set extras, int perPage, int page) throws IOException, SAXException,
            FlickrException {
        PhotoList photos = new PhotoList();

        List parameters = new ArrayList();
        parameters.add(new Parameter("method", METHOD_GET_PUBLIC_PHOTOS));
        parameters.add(new Parameter("api_key", apiKey));

        parameters.add(new Parameter("user_id", userId));

        if (perPage > 0) {
            parameters.add(new Parameter("per_page", "" + perPage));
        }
        if (page > 0) {
            parameters.add(new Parameter("page", "" + page));
        }

        if (extras != null) {
            parameters.add(new Parameter(Extras.KEY_EXTRAS, StringUtilities.join(extras, ",")));
        }
        parameters.add(
            new Parameter(
                "api_sig",
                AuthUtilities.getSignature(sharedSecret, parameters)
            )
        );

        Response response = transportAPI.get(transportAPI.getPath(), parameters);
        if (response.isError()) {
            throw new FlickrException(response.getErrorCode(), response.getErrorMessage());
        }
        Element photosElement = response.getPayload();
        photos.setPage(photosElement.getAttribute("page"));
    photos.setPages(photosElement.getAttribute("pages"));
    photos.setPerPage(photosElement.getAttribute("perpage"));
    photos.setTotal(photosElement.getAttribute("total"));

        NodeList photoNodes = photosElement.getElementsByTagName("photo");
        for (int i = 0; i < photoNodes.getLength(); i++) {
            Element photoElement = (Element) photoNodes.item(i);
            photos.add(PhotoUtils.createPhoto(photoElement));
        }
        return photos;
    }
View Full Code Here

Examples of com.aetrion.flickr.photos.PhotoList

     * @throws FlickrException
     */
    public PhotoList getPhotos(String photosetId, Set extras,
      int privacy_filter, int perPage, int page)
      throws IOException, SAXException, FlickrException {
        PhotoList photos = new PhotoList();
        List parameters = new ArrayList();
        parameters.add(new Parameter("method", METHOD_GET_PHOTOS));
        parameters.add(new Parameter("api_key", apiKey));

        parameters.add(new Parameter("photoset_id", photosetId));

        if (perPage > 0) {
            parameters.add(new Parameter("per_page", new Integer(perPage)));
        }

        if (page > 0) {
            parameters.add(new Parameter("page", new Integer(page)));
        }

        if (privacy_filter > 0) {
            parameters.add(new Parameter("privacy_filter", "" + privacy_filter));
        }

        if (extras != null && !extras.isEmpty()) {
            parameters.add(new Parameter(Extras.KEY_EXTRAS, StringUtilities.join(extras, ",")));
        }
        parameters.add(
            new Parameter(
                "api_sig",
                AuthUtilities.getSignature(sharedSecret, parameters)
            )
        );

        Response response = transportAPI.get(transportAPI.getPath(), parameters);
        if (response.isError()) {
            throw new FlickrException(response.getErrorCode(), response.getErrorMessage());
        }

        Element photoset = response.getPayload();
        NodeList photoElements = photoset.getElementsByTagName("photo");
        photos.setPage(photoset.getAttribute("page"));
        photos.setPages(photoset.getAttribute("pages"));
        photos.setPerPage(photoset.getAttribute("per_page"));
        photos.setTotal(photoset.getAttribute("total"));

        for (int i = 0; i < photoElements.getLength(); i++) {
            Element photoElement = (Element) photoElements.item(i);
            photos.add(PhotoUtils.createPhoto(photoElement, photoset));
        }

        return photos;
    }
View Full Code Here

Examples of com.aetrion.flickr.photos.PhotoList

  public void run()
  {
    String programWorkingFolder = Program.getFolder();
    File dataFile = new File(programWorkingFolder + DATA_FILE);
   
    PhotoList photoListPrevious = GetPreviousPhotoList( dataFile );
    PhotoList newPhotoList = null;
   
    boolean contactFlickr = false;

    // No saved photo list found, must access flickr data.
    if( photoListPrevious == null )
      contactFlickr = true;
   
    if( !contactFlickr )
    {
      String lastConnectionProp = Program.getProperty("flickr.lastConnection");       
      String daysToReconnectProp = Program.getProperty("flickr.daysToReconnect");
     
      contactFlickr = CheckPastUpdateDate( lastConnectionProp, daysToReconnectProp );
    }
   
    if( contactFlickr )
    {
      newPhotoList = GetPhotoListFromFlickr();

      if( newPhotoList != null )
      {
        //
        // Set the new contact date.
        //
        DateFormat dfm = new SimpleDateFormat("yyyy-MM-dd");
        String today = dfm.format(new Date());
       
        Program.setProperty("flickr.lastConnection", today);
       
        //
        // Save the new list of photos
        //
        FileOutputStream f_out = null;
        try
        {
          f_out = new FileOutputStream( programWorkingFolder + DATA_FILE );
          ObjectOutputStream obj_out = new ObjectOutputStream (f_out);
          obj_out.writeObject ( newPhotoList );
        }
        catch (Exception e) {}// FileNotFoundException, IOException
        finally
        {
          if( f_out != null )
          {
            try {
              f_out.close();
            } catch (IOException e) {}
          }
        }
      }
    }

    PhotoList photoListToShow = photoListPrevious;
   
    if( newPhotoList != null )
      photoListToShow = newPhotoList;
     
    if( photoListToShow == null )
      return;
   
    //
    // Add the photos, download if necessary?
    //
    String storeFolder = programWorkingFolder + STORE_FOLDER;
    String tempFolder = System.getProperty("java.io.tmpdir");
    if( tempFolder.isEmpty() )
      tempFolder = programWorkingFolder + TEMP_FOLDER;
    else
      tempFolder += File.separator + TEMP_FOLDER;
   
    File checkFolder = new File( storeFolder );
    if( !checkFolder.exists() )
      checkFolder.mkdirs();
   
    checkFolder = new File( tempFolder );
    if( !checkFolder.exists() )
      checkFolder.mkdirs();
   
   
    // TODO: Check if file already exists, but delete ones we aren't using any more.
    // Should only be less than the number of photos allowed to be downloaded some
    // may need to delete before downloading
   
    @SuppressWarnings("unchecked")
    Iterator<com.aetrion.flickr.photos.Photo> i = (Iterator<com.aetrion.flickr.photos.Photo>)photoListToShow.iterator();
   
      for(; i.hasNext();)
      {
        com.aetrion.flickr.photos.Photo photo = i.next();
       
View Full Code Here

Examples of com.aetrion.flickr.photos.PhotoList

    //
      // Connect to flickr
      //
    Flickr flickr = new Flickr( this._api_key, this._api_secret, rest );
   
    PhotoList newPhotoList = null;
   
    String userToken = Program.getProperty( "flickr.userToken" );
    String sPhotosets = Program.getProperty( "flickr.photosets" );
   
    if( sPhotosets != "" )
    {
      PhotosetsInterface photosetsI = flickr.getPhotosetsInterface();
     
      Photosets photosets = null;
     
      try
      {
        photosets = photosetsI.getList(userToken);
      }
      catch (Exception e) //IOException e2, SAXException e2, FlickrException e2) {
      {
        e.printStackTrace();
        return null;
      }
     
      if( photosets != null )
      {
        // If we have a list of photosets, just get the photos from there.
        @SuppressWarnings("unchecked")
        Collection<Photoset> photosetCollection = photosets.getPhotosets();
     
        PhotoList photosetsPhotoList = new PhotoList();
       
        String[] photosetsNamesArray = sPhotosets.split(";");
       
        int photosetsPhotoCount = photoCount / photosetsNamesArray.length;
        int photosetsPhotoCountExtra = 0;
        for( Photoset photoset : photosetCollection )
        {
          String photosetName = photoset.getTitle();
          for( int i = 0; i<photosetsNamesArray.length;i++)
          {
            if( photosetsNamesArray[i] != "" &&
                photosetsNamesArray[i].compareToIgnoreCase(photosetName) == 0 )
            {
              PhotoList photoList = null;
              try
              {
                photoList = photosetsI.getPhotos(photoset.getId(), photosetsPhotoCount + photosetsPhotoCountExtra, 1);
              }
              catch( Exception e) //catch (IOException e), catch (SAXException e), catch (FlickrException e)
              {
                e.printStackTrace();
                return null;
              }
             
              if( photoList != null )
              {
                @SuppressWarnings("unchecked")
                Iterator<com.aetrion.flickr.photos.Photo> p = (Iterator<com.aetrion.flickr.photos.Photo>)photoList.iterator();
               
                int photosAdded = 0;
                  for(; p.hasNext();)
                  {
                    com.aetrion.flickr.photos.Photo photo = p.next();
View Full Code Here

Examples of com.aetrion.flickr.photos.PhotoList

    return pastDate;
  }

  private PhotoList GetPreviousPhotoList(File dataFile)
  {
    PhotoList photoList = null;
   
    if( dataFile != null && dataFile.exists() )
    {
      //
      // Read the saved photolist if it exists.
View Full Code Here

Examples of com.aetrion.flickr.photos.PhotoList

     * @throws SAXException
     * @see com.aetrion.flickr.photos.Extras
     */
    public PhotoList getList(String date, Set extras, int perPage, int page) throws FlickrException, IOException, SAXException {
        List parameters = new ArrayList();
        PhotoList photos = new PhotoList();

        parameters.add(new Parameter(KEY_METHOD, METHOD_GET_LIST));
        parameters.add(new Parameter(KEY_API_KEY, apiKey));

        if (date != null) {
             parameters.add(new Parameter(KEY_DATE, date));
        }

        if (extras != null) {
            parameters.add(new Parameter(KEY_EXTRAS, StringUtilities.join(extras, ",")));
        }

        if (perPage > 0) {
            parameters.add(new Parameter(KEY_PER_PAGE, String.valueOf(perPage)));
        }
        if (page > 0) {
            parameters.add(new Parameter(KEY_PAGE, String.valueOf(page)));
        }
        parameters.add(
            new Parameter(
                "api_sig",
                AuthUtilities.getSignature(sharedSecret, parameters)
            )
        );

        Response response = transportAPI.get(transportAPI.getPath(), parameters);
        if (response.isError()) {
            throw new FlickrException(response.getErrorCode(), response.getErrorMessage());
        }
        Element photosElement = response.getPayload();
        photos.setPage(photosElement.getAttribute("page"));
        photos.setPages(photosElement.getAttribute("pages"));
        photos.setPerPage(photosElement.getAttribute("perpage"));
        photos.setTotal(photosElement.getAttribute("total"));

        NodeList photoNodes = photosElement.getElementsByTagName("photo");
        for (int i = 0; i < photoNodes.getLength(); i++) {
            Element photoElement = (Element) photoNodes.item(i);
            Photo photo = PhotoUtils.createPhoto(photoElement);
            photos.add(photo);
        }
        return photos;
    }
View Full Code Here

Examples of com.aetrion.flickr.photos.PhotoList

        System.out.println();
      }
      */
     
      boolean isGeoSearch = this.isGeoSearch(this.getSearchParameters());
      PhotoList fotoList = this.getSearchedFotoList(this.getSearchParameters(), this.getFotoLoadCount(), this.getSearchPageOffset(), isGeoSearch);
     
      if (fotoList != null && fotoList.size() > 0){
//        System.out.println("Found " + fotoList.size() + " fotos.");
       
        this.setTarget(fotoList.size());
//        mtFotos = new ImageCard[fotoList.size()];
       
        //Go through all found fotos
        for (int i = 0; i < fotoList.size(); i++) {
         
          try {
            Thread.sleep(this.getSleepTime());
          } catch (InterruptedException e) {
            e.printStackTrace();
            //pa.unregisterPre(this);
            this.setFinished(true);
            break;
          }
         
          Photo foto = (Photo) fotoList.get(i);
          String fotoName = foto.getTitle();
         
          /*
          if (foto.hasGeoData()){
            System.out.println("Foto: " + fotoName + " has geodata.");
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.