Exemplo n.º 1
0
 public ImplRaceDriverService() throws IOException, ServiceException {
   drivers = new ArrayList<RaceDriver>();
   Query myQuery = new Query(feedURL);
   myQuery.setStringCustomParameter("kind", "photo");
   myQuery.setStringCustomParameter("tag", "Driver");
   AlbumFeed feed = picasawebService.query(myQuery, AlbumFeed.class);
   for (PhotoEntry photo : feed.getPhotoEntries()) {
     RaceDriver driver = new RaceDriver();
     driver.setName(photo.getDescription().getPlainText());
     driver.setUrl(photo.getMediaContents().get(0).getUrl());
     Query tagQuery =
         new Query(
             new URL(
                 "https://picasaweb.google.com/data/feed/api/user/107302466601293793664/albumid/"
                     + photo.getAlbumId()
                     + "/photoid/"
                     + photo.getGphotoId()
                     + "?kind=tag"));
     AlbumFeed tags = picasawebService.query(tagQuery, AlbumFeed.class);
     for (TagEntry tag : tags.getTagEntries()) {
       if (tag.getTitle().getPlainText().startsWith("wiki:")) {
         driver.setWikiUrl(tag.getTitle().getPlainText().substring(5));
       }
     }
     drivers.add(driver);
   }
 }
Exemplo n.º 2
0
  /** @param directory Directory where we list tags */
  @Override
  protected void buildTagList(File directory) {
    this.tagList = new TreeSet<TagEntry>();
    ArrayList<String> argv = new ArrayList<String>();
    ensureCommand(CMD_PROPERTY_KEY, CMD_FALLBACK);
    argv.add(cmd);
    argv.add("tags");
    ProcessBuilder pb = new ProcessBuilder(argv);
    pb.directory(directory);
    Process process = null;
    BufferedReader in = null;

    try {
      process = pb.start();
      in = new BufferedReader(new InputStreamReader(process.getInputStream()));
      String line;
      while ((line = in.readLine()) != null) {
        String parts[] = line.split("  *");
        if (parts.length < 2) {
          throw new HistoryException("Tag line contains more than 2 columns: " + line);
        }
        // Grrr, how to parse tags with spaces inside?
        // This solution will loose multiple spaces;-/
        String tag = parts[0];
        for (int i = 1; i < parts.length - 1; ++i) {
          tag += " " + parts[i];
        }
        TagEntry tagEntry = new BazaarTagEntry(Integer.parseInt(parts[parts.length - 1]), tag);
        // Bazaar lists multiple tags on more lines. We need to merge those into single TagEntry
        TagEntry higher = this.tagList.ceiling(tagEntry);
        if (higher != null && higher.equals(tagEntry)) {
          // Found in the tree, merge tags
          this.tagList.remove(higher);
          tagEntry.setTags(higher.getTags() + ", " + tag);
        }
        this.tagList.add(tagEntry);
      }
    } catch (IOException e) {
      OpenGrokLogger.getLogger().log(Level.WARNING, "Failed to read tag list: {0}", e.getMessage());
      this.tagList = null;
    } catch (HistoryException e) {
      OpenGrokLogger.getLogger()
          .log(Level.WARNING, "Failed to parse tag list: {0}", e.getMessage());
      this.tagList = null;
    }

    IOUtils.close(in);
    if (process != null) {
      try {
        process.exitValue();
      } catch (IllegalThreadStateException e) {
        // the process is still running??? just kill it..
        process.destroy();
      }
    }
  }
Exemplo n.º 3
0
 /**
  * Assign tags to changesets they represent The complete list of tags must be pre-built using
  * {@code getTagList()}. Then this function squeeze all tags to changesets which actually exist in
  * the history of given file. Must be implemented repository-specific.
  *
  * @see getTagList
  * @param hist History we want to assign tags to.
  */
 void assignTagsInHistory(History hist) throws HistoryException {
   if (hist == null) {
     return;
   }
   if (this.getTagList() == null) {
     throw new HistoryException("Tag list was not created before assigning tags to changesets!");
   }
   Iterator<TagEntry> it = this.getTagList().descendingIterator();
   TagEntry lastTagEntry = null;
   // Go through all commits of given file
   for (HistoryEntry ent : hist.getHistoryEntries()) {
     // Assign all tags created since the last revision
     // Revision in this HistoryEntry must be already specified!
     // TODO is there better way to do this? We need to "repeat"
     // last element returned by call to next()
     while (lastTagEntry != null || it.hasNext()) {
       if (lastTagEntry == null) {
         lastTagEntry = it.next();
       }
       if (lastTagEntry.compareTo(ent) >= 0) {
         if (ent.getTags() == null) {
           ent.setTags(lastTagEntry.getTags());
         } else {
           ent.setTags(ent.getTags() + ", " + lastTagEntry.getTags());
         }
       } else {
         break;
       }
       if (it.hasNext()) {
         lastTagEntry = it.next();
       } else {
         lastTagEntry = null;
       }
     }
   }
 }