Changeset 6695 in josm
- Timestamp:
- 2014-01-15T23:39:56+01:00 (11 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/io
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/io/MessageNotifier.java
r6453 r6695 59 59 public void run() { 60 60 try { 61 final UserInfo userInfo = new OsmServerUserInfoReader().fetchUserInfo(NullProgressMonitor.INSTANCE); 61 final UserInfo userInfo = new OsmServerUserInfoReader().fetchUserInfo(NullProgressMonitor.INSTANCE, tr("get number of unread messages")); 62 62 final int unread = userInfo.getUnreadMessages(); 63 63 if (unread > 0 && unread != lastUnreadCount) { -
trunk/src/org/openstreetmap/josm/io/OsmServerReader.java
r6643 r6695 47 47 * @param urlStr The url to connect to. 48 48 * @param progressMonitor progress monitoring and abort handler 49 * @return A nreader reading the input stream (servers answer) or <code>null</code>.49 * @return A reader reading the input stream (servers answer) or <code>null</code>. 50 50 * @throws OsmTransferException thrown if data transfer errors occur 51 51 */ 52 52 protected InputStream getInputStream(String urlStr, ProgressMonitor progressMonitor) throws OsmTransferException { 53 return getInputStream(urlStr, progressMonitor, null); 54 } 55 56 /** 57 * Open a connection to the given url and return a reader on the input stream 58 * from that connection. In case of user cancel, return <code>null</code>. 59 * Relative URL's are directed to API base URL. 60 * @param urlStr The url to connect to. 61 * @param progressMonitor progress monitoring and abort handler 62 * @param reason The reason to show on console. Can be {@code null} if no reason is given 63 * @return A reader reading the input stream (servers answer) or <code>null</code>. 64 * @throws OsmTransferException thrown if data transfer errors occur 65 */ 66 protected InputStream getInputStream(String urlStr, ProgressMonitor progressMonitor, String reason) throws OsmTransferException { 53 67 try { 54 68 api.initialize(progressMonitor); 55 urlStr= urlStr.startsWith("http") ? urlStr : (getBaseUrl() + urlStr);56 return getInputStreamRaw(url Str, progressMonitor);69 String url = urlStr.startsWith("http") ? urlStr : (getBaseUrl() + urlStr); 70 return getInputStreamRaw(url, progressMonitor, reason); 57 71 } finally { 58 72 progressMonitor.invalidate(); … … 61 75 62 76 /** 63 * Ret run the base URL for relative URL requests77 * Return the base URL for relative URL requests 64 78 * @return base url of API 65 79 */ … … 77 91 */ 78 92 protected InputStream getInputStreamRaw(String urlStr, ProgressMonitor progressMonitor) throws OsmTransferException { 93 return getInputStreamRaw(urlStr, progressMonitor, null); 94 } 95 96 /** 97 * Open a connection to the given url and return a reader on the input stream 98 * from that connection. In case of user cancel, return <code>null</code>. 99 * @param urlStr The exact url to connect to. 100 * @param progressMonitor progress monitoring and abort handler 101 * @param reason The reason to show on console. Can be {@code null} if no reason is given 102 * @return An reader reading the input stream (servers answer) or <code>null</code>. 103 * @throws OsmTransferException thrown if data transfer errors occur 104 */ 105 protected InputStream getInputStreamRaw(String urlStr, ProgressMonitor progressMonitor, String reason) throws OsmTransferException { 79 106 try { 80 107 URL url = null; … … 107 134 108 135 try { 109 Main.info("GET " + url); 136 if (reason != null && !reason.isEmpty()) { 137 Main.info("GET " + url + " (" + reason + ")"); 138 } else { 139 Main.info("GET " + url); 140 } 110 141 activeConnection.connect(); 111 142 } catch (Exception e) { -
trunk/src/org/openstreetmap/josm/io/OsmServerUserInfoReader.java
r6365 r6695 144 144 } 145 145 146 /** 147 * Fetches user info, without explicit reason. 148 * @param monitor The progress monitor 149 * @return The user info 150 * @throws OsmTransferException if something goes wrong 151 */ 146 152 public UserInfo fetchUserInfo(ProgressMonitor monitor) throws OsmTransferException { 153 return fetchUserInfo(monitor, null); 154 } 155 156 /** 157 * Fetches user info, with an explicit reason. 158 * @param monitor The progress monitor 159 * @param reason The reason to show on console. Can be {@code null} if no reason is given 160 * @return The user info 161 * @throws OsmTransferException if something goes wrong 162 * @since 6695 163 */ 164 public UserInfo fetchUserInfo(ProgressMonitor monitor, String reason) throws OsmTransferException { 147 165 try { 148 166 monitor.beginTask(""); 149 167 monitor.indeterminateSubTask(tr("Reading user info ...")); 150 InputStream in = getInputStream("user/details", monitor.createSubTaskMonitor(1, true)); 168 InputStream in = getInputStream("user/details", monitor.createSubTaskMonitor(1, true), reason); 151 169 return buildFromXML( 152 170 DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(in)
Note:
See TracChangeset
for help on using the changeset viewer.