Ignore:
Timestamp:
28.12.2009 00:15:22 (2 years ago)
Author:
Gubaer
Message:

Partial commit due to issue described in #4137
Breaks the build

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/io/OsmServerChangesetReader.java

    r2613 r2688  
    66 
    77import java.io.InputStream; 
     8import java.io.UnsupportedEncodingException; 
    89import java.util.ArrayList; 
    910import java.util.Collection; 
     
    1314 
    1415import org.openstreetmap.josm.data.osm.Changeset; 
     16import org.openstreetmap.josm.data.osm.ChangesetDataSet; 
    1517import org.openstreetmap.josm.data.osm.DataSet; 
    1618import org.openstreetmap.josm.gui.progress.NullProgressMonitor; 
     
    140142                if (in == null) 
    141143                    return null; 
    142                 monitor.indeterminateSubTask(tr("({0}/{1}) Downloading changeset {0} ...", i,ids.size(), id)); 
     144                monitor.indeterminateSubTask(tr("({0}/{1}) Downloading changeset {2} ...", i,ids.size(), id)); 
    143145                List<Changeset> changesets = OsmChangesetParser.parse(in, monitor.createSubTaskMonitor(1, true)); 
    144146                if (changesets == null || changesets.isEmpty()) { 
     
    159161 
    160162    /** 
    161      * not implemented yet 
     163     * Downloads the content of a changeset 
    162164     * 
    163      * @param id 
    164      * @param monitor 
    165      * @return 
    166      * @throws OsmTransferException 
     165     * @param id the changset id. >0 required. 
     166     * @param monitor the progress monitor. {@see NullProgressMonitor#INSTANCE} assumed if null. 
     167     * @return the changset content 
     168     * @throws IllegalArgumentException thrown if id <= 0 
     169     * @throws OsmTransferException thrown if something went wrong 
    167170     */ 
    168     public Changeset downloadChangeset(long id, ProgressMonitor monitor) throws OsmTransferException { 
    169         return null; 
     171    public ChangesetDataSet downloadChangeset(int id, ProgressMonitor monitor) throws IllegalArgumentException, OsmTransferException { 
     172        if (id <= 0) 
     173            throw new IllegalArgumentException(tr("Expected value of type integer > 0 for parameter ''{0}'', got {1}", "id", id)); 
     174        if (monitor == null) { 
     175            monitor = NullProgressMonitor.INSTANCE; 
     176        } 
     177        try { 
     178            monitor.beginTask(tr("Downloading changeset content")); 
     179            StringBuffer sb = new StringBuffer(); 
     180            sb.append("changeset/").append(id).append("/download"); 
     181            InputStream in = getInputStream(sb.toString(), monitor.createSubTaskMonitor(1, true)); 
     182            if (in == null) 
     183                return null; 
     184            monitor.setCustomText(tr("Downloading content for changeset {0} ...", id)); 
     185            OsmChangesetContentParser parser = new OsmChangesetContentParser(in); 
     186            ChangesetDataSet ds = parser.parse(monitor.createSubTaskMonitor(1, true)); 
     187            return ds; 
     188        } catch(UnsupportedEncodingException e) { 
     189            throw new OsmTransferException(e); 
     190        } catch(OsmDataParsingException e) { 
     191            throw new OsmTransferException(e); 
     192        } finally { 
     193            monitor.finishTask(); 
     194        } 
    170195    } 
    171196} 
Note: See TracChangeset for help on using the changeset viewer.