Changeset 4145 in josm
- Timestamp:
- 2011-06-19T15:11:18+02:00 (13 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/imagery/ImageryLayerInfo.java
r4016 r4145 58 58 } 59 59 MirroredInputStream s = new MirroredInputStream(source, -1); 60 InputStreamReader r; 61 try 62 { 63 r = new InputStreamReader(s, "UTF-8"); 64 } 65 catch (UnsupportedEncodingException e) 66 { 67 r = new InputStreamReader(s); 68 } 69 BufferedReader reader = new BufferedReader(r); 70 String line; 71 while((line = reader.readLine()) != null) 72 { 73 String val[] = line.split(";"); 74 if(!line.startsWith("#") && (val.length == 3 || val.length == 4)) { 75 boolean force = "true".equals(val[0]); 76 String name = tr(val[1]); 77 String url = val[2]; 78 String eulaAcceptanceRequired = null; 60 try { 61 InputStreamReader r; 62 try 63 { 64 r = new InputStreamReader(s, "UTF-8"); 65 } 66 catch (UnsupportedEncodingException e) 67 { 68 r = new InputStreamReader(s); 69 } 70 BufferedReader reader = new BufferedReader(r); 71 String line; 72 while((line = reader.readLine()) != null) 73 { 74 String val[] = line.split(";"); 75 if(!line.startsWith("#") && (val.length == 3 || val.length == 4)) { 76 boolean force = "true".equals(val[0]); 77 String name = tr(val[1]); 78 String url = val[2]; 79 String eulaAcceptanceRequired = null; 79 80 80 if (val.length == 4) {81 // 4th parameter optional for license agreement (EULA)82 eulaAcceptanceRequired = val[3];83 }81 if (val.length == 4) { 82 // 4th parameter optional for license agreement (EULA) 83 eulaAcceptanceRequired = val[3]; 84 } 84 85 85 defaultLayers.add(new ImageryInfo(name, url, eulaAcceptanceRequired));86 defaultLayers.add(new ImageryInfo(name, url, eulaAcceptanceRequired)); 86 87 87 if (force) { 88 defaultsSave.add(url); 89 if (!defaults.contains(url)) { 90 for (ImageryInfo i : layers) { 91 if ((i.getImageryType() == ImageryType.WMS && url.equals(i.getUrl())) 92 || url.equals(i.getFullUrl())) { 93 force = false; 88 if (force) { 89 defaultsSave.add(url); 90 if (!defaults.contains(url)) { 91 for (ImageryInfo i : layers) { 92 if ((i.getImageryType() == ImageryType.WMS && url.equals(i.getUrl())) 93 || url.equals(i.getFullUrl())) { 94 force = false; 95 } 94 96 } 95 }96 if (force) {97 add(new ImageryInfo(name, url));97 if (force) { 98 add(new ImageryInfo(name, url)); 99 } 98 100 } 99 101 } 100 102 } 101 103 } 104 } finally { 105 s.close(); 102 106 } 103 107 } -
trunk/src/org/openstreetmap/josm/gui/tagging/TaggingPreset.java
r4056 r4145 1232 1232 1233 1233 public static Collection<TaggingPreset> readAll(String source, boolean validate) throws SAXException, IOException { 1234 Collection<TaggingPreset> tp; 1234 1235 MirroredInputStream s = new MirroredInputStream(source); 1235 InputStream zip = s.getZipEntry("xml","preset"); 1236 if(zip != null) { 1237 zipIcons = s.getFile(); 1238 } 1239 InputStreamReader r; 1240 try 1241 { 1242 r = new InputStreamReader(zip == null ? s : zip, "UTF-8"); 1243 } 1244 catch (UnsupportedEncodingException e) 1245 { 1246 r = new InputStreamReader(zip == null ? s: zip); 1247 } 1248 return TaggingPreset.readAll(new BufferedReader(r), validate); 1236 try { 1237 InputStream zip = s.getZipEntry("xml","preset"); 1238 if(zip != null) { 1239 zipIcons = s.getFile(); 1240 } 1241 InputStreamReader r; 1242 try { 1243 r = new InputStreamReader(zip == null ? s : zip, "UTF-8"); 1244 } catch (UnsupportedEncodingException e) { 1245 r = new InputStreamReader(zip == null ? s: zip); 1246 } 1247 try { 1248 tp = TaggingPreset.readAll(new BufferedReader(r), validate); 1249 } finally { 1250 r.close(); 1251 } 1252 } finally { 1253 s.close(); 1254 } 1255 return tp; 1249 1256 } 1250 1257 -
trunk/src/org/openstreetmap/josm/io/MirroredInputStream.java
r4130 r4145 221 221 conn.setReadTimeout(5000); 222 222 bis = new BufferedInputStream(conn.getInputStream()); 223 bos = new BufferedOutputStream( new FileOutputStream(destDirFile)); 223 FileOutputStream fos = new FileOutputStream(destDirFile); 224 bos = new BufferedOutputStream(fos); 224 225 byte[] buffer = new byte[4096]; 225 226 int length; … … 229 230 bos.close(); 230 231 bos = null; 232 /* close fos as well to be sure! */ 233 fos.close(); 234 fos = null; 231 235 file = new File(destDir, localPath); 232 destDirFile.renameTo(file); 233 Main.pref.putCollection(prefKey, Arrays.asList(new String[] 234 {Long.toString(System.currentTimeMillis()), file.toString()})); 236 if(destDirFile.renameTo(file)) { 237 Main.pref.putCollection(prefKey, Arrays.asList(new String[] 238 {Long.toString(System.currentTimeMillis()), file.toString()})); 239 } else { 240 System.out.println(tr("Failed to rename file {0} to {1}.", 241 destDirFile.getPath(), file.getPath())); 242 } 235 243 } catch (IOException e) { 236 244 if (age >= maxTime*1000 && age < maxTime*1000*2) { -
trunk/src/org/openstreetmap/josm/plugins/PluginInformation.java
r3936 r4145 79 79 this.name = name; 80 80 this.file = file; 81 FileInputStream fis = null; 81 82 JarInputStream jar = null; 82 83 try { 83 jar = new JarInputStream(new FileInputStream(file)); 84 fis = new FileInputStream(file); 85 jar = new JarInputStream(fis); 84 86 Manifest manifest = jar.getManifest(); 85 87 if (manifest == null) … … 93 95 try { 94 96 jar.close(); 97 } catch(IOException e) { /* ignore */ } 98 } 99 if (fis != null) { 100 try { 101 fis.close(); 95 102 } catch(IOException e) { /* ignore */ } 96 103 }
Note:
See TracChangeset
for help on using the changeset viewer.