Changeset 2124 in josm
- Timestamp:
- 2009-09-13T22:46:45+02:00 (15 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/io
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/io/OsmConnection.java
r2037 r2124 14 14 import java.nio.charset.Charset; 15 15 import java.nio.charset.CharsetEncoder; 16 import java.util.logging.Logger; 16 17 17 18 import javax.swing.JCheckBox; … … 23 24 import org.openstreetmap.josm.Main; 24 25 import org.openstreetmap.josm.gui.ExtendedDialog; 25 import org.openstreetmap.josm.gui.progress.ProgressMonitor;26 26 import org.openstreetmap.josm.tools.Base64; 27 27 import org.openstreetmap.josm.tools.GBC; … … 34 34 */ 35 35 public class OsmConnection { 36 private static final Logger logger = Logger.getLogger(OsmConnection.class.getName()); 36 37 37 38 protected boolean cancel = false; -
trunk/src/org/openstreetmap/josm/io/OsmServerChangesetReader.java
r2115 r2124 7 7 import org.openstreetmap.josm.data.osm.Changeset; 8 8 import org.openstreetmap.josm.data.osm.DataSet; 9 import org.openstreetmap.josm.gui.progress.NullProgressMonitor; 9 10 import org.openstreetmap.josm.gui.progress.ProgressMonitor; 10 11 import static org.openstreetmap.josm.tools.I18n.tr; … … 21 22 */ 22 23 public OsmServerChangesetReader(){ 24 setDoAuthenticate(false); 23 25 } 24 26 … … 32 34 } 33 35 34 36 /** 37 * Queries a list 38 * @param query the query specification. Must not be null. 39 * @param monitor a progress monitor. Set to {@see NullProgressMonitor#INSTANCE} if null 40 * @return the list of changesets read from the server 41 * @throws IllegalArgumentException thrown if query is null 42 * @throws OsmTransferException 43 */ 35 44 public List<Changeset> queryChangesets(ChangesetQuery query, ProgressMonitor monitor) throws OsmTransferException { 45 if (query == null) 46 throw new IllegalArgumentException(tr("parameter ''{0}'' must not be null", "query")); 47 if (monitor == null) { 48 monitor = NullProgressMonitor.INSTANCE; 49 } 36 50 try { 37 monitor.beginTask(tr("Reading changesets s..."));51 monitor.beginTask(tr("Reading changesets...")); 38 52 StringBuffer sb = new StringBuffer(); 39 53 sb.append("changesets?").append(query.getQueryString()); … … 53 67 } 54 68 69 /** 70 * Reads teh changeset with id <code>id</code> from the server 71 * 72 * @param id the changeset id. id > 0 required. 73 * @param monitor the progress monitor. Set to {@see NullProgressMonitor#INSTANCE} if null 74 * @return the changeset read 75 * @throws OsmTransferException thrown if something goes wrong 76 * @throws IllegalArgumentException if id <= 0 77 */ 55 78 public Changeset readChangeset(long id, ProgressMonitor monitor) throws OsmTransferException { 79 if (id <= 0) 80 throw new IllegalArgumentException(tr("parameter ''{0}'' > 0 expected. Got {1}", "id", id)); 81 if (monitor == null) { 82 monitor = NullProgressMonitor.INSTANCE; 83 } 56 84 try { 57 85 monitor.beginTask(tr("Reading changeset {0} ...",id)); … … 61 89 if (in == null) 62 90 return null; 63 monitor.indeterminateSubTask(tr("Downloading changeset ..."));91 monitor.indeterminateSubTask(tr("Downloading changeset {0} ...", id)); 64 92 List<Changeset> changesets = OsmChangesetParser.parse(in, monitor.createSubTaskMonitor(1, true)); 65 93 if (changesets == null || changesets.isEmpty()) … … 75 103 } 76 104 105 /** 106 * not implemented yet 107 * 108 * @param id 109 * @param monitor 110 * @return 111 * @throws OsmTransferException 112 */ 77 113 public Changeset downloadChangeset(long id, ProgressMonitor monitor) throws OsmTransferException { 78 114 return null; 79 115 } 80 81 116 } -
trunk/src/org/openstreetmap/josm/io/OsmServerReader.java
r2035 r2124 10 10 import java.net.MalformedURLException; 11 11 import java.net.URL; 12 import java.nio.charset.CharacterCodingException; 12 13 import java.util.zip.GZIPInputStream; 13 14 import java.util.zip.Inflater; … … 30 31 31 32 private OsmApi api = OsmApi.getOsmApi(); 33 private boolean doAuthenticate = false; 32 34 33 35 /** … … 66 68 } 67 69 70 try { 71 if (doAuthenticate) { 72 addAuth(activeConnection); 73 } 74 } catch(CharacterCodingException e) { 75 System.err.println(tr("Error: failed to add authentication credentials to the connection.")); 76 throw new OsmTransferException(e); 77 } 68 78 if (Main.pref.getBoolean("osm-server.use-compression", true)) { 69 79 activeConnection.setRequestProperty("Accept-Encoding", "gzip, deflate"); … … 122 132 public abstract DataSet parseOsm(ProgressMonitor progressMonitor) throws OsmTransferException; 123 133 134 /** 135 * Returns true if this reader is adding authentication credentials to the read 136 * request sent to the server. 137 * 138 * @return true if this reader is adding authentication credentials to the read 139 * request sent to the server 140 */ 141 public boolean isDoAuthenticate() { 142 return doAuthenticate; 143 } 144 145 /** 146 * Sets whether this reader adds authentication credentials to the read 147 * request sent to the server. 148 * 149 * @param doAuthenticate true if this reader adds authentication credentials to the read 150 * request sent to the server 151 */ 152 public void setDoAuthenticate(boolean doAuthenticate) { 153 this.doAuthenticate = doAuthenticate; 154 } 124 155 } -
trunk/src/org/openstreetmap/josm/io/OsmServerUserInfoReader.java
r2115 r2124 24 24 25 25 public class OsmServerUserInfoReader extends OsmServerReader { 26 27 public OsmServerUserInfoReader() { 28 setDoAuthenticate(true); 29 } 26 30 27 31 @Override
Note:
See TracChangeset
for help on using the changeset viewer.