Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/plugins/PluginInformation.java
r13204 r13993 84 84 /** All manifest attributes. */ 85 85 public final Map<String, String> attr = new TreeMap<>(); 86 /** Invalid manifest entries */ 87 final List<String> invalidManifestEntries = new ArrayList<>(); 86 88 /** Empty icon for these plugins which have none */ 87 89 private static final ImageIcon emptyIcon = ImageProvider.getEmpty(ImageProvider.ImageSizes.LARGEICON); … … 175 177 this.attr.clear(); 176 178 this.attr.putAll(other.attr); 179 this.invalidManifestEntries.clear(); 180 this.invalidManifestEntries.addAll(other.invalidManifestEntries); 177 181 } 178 182 … … 248 252 } 249 253 canloadatruntime = Boolean.parseBoolean(attr.getValue("Plugin-Canloadatruntime")); 250 if (oldcheck && mainversion > Version.getInstance().getVersion()) { 251 int myv = Version.getInstance().getVersion(); 252 for (Map.Entry<Object, Object> entry : attr.entrySet()) { 254 int myv = Version.getInstance().getVersion(); 255 for (Map.Entry<Object, Object> entry : attr.entrySet()) { 256 String key = ((Attributes.Name) entry.getKey()).toString(); 257 if (key.endsWith("_Plugin-Url")) { 253 258 try { 254 String key = ((Attributes.Name) entry.getKey()).toString(); 255 if (key.endsWith("_Plugin-Url")) { 256 int mv = Integer.parseInt(key.substring(0, key.length()-11)); 257 if (mv <= myv && (mv > mainversion || mainversion > myv)) { 258 String v = (String) entry.getValue(); 259 int i = v.indexOf(';'); 260 if (i > 0) { 261 downloadlink = v.substring(i+1); 262 mainversion = mv; 263 version = v.substring(0, i); 264 oldmode = true; 265 } 266 } 259 int mv = Integer.parseInt(key.substring(0, key.length()-11)); 260 String v = (String) entry.getValue(); 261 int i = v.indexOf(';'); 262 if (i <= 0) { 263 invalidManifestEntries.add(key); 264 } else if (oldcheck && mainversion > Version.getInstance().getVersion() && 265 mv <= myv && (mv > mainversion || mainversion > myv)) { 266 downloadlink = v.substring(i+1); 267 mainversion = mv; 268 version = v.substring(0, i); 269 oldmode = true; 267 270 } 268 } catch (NumberFormatException e) { 271 } catch (NumberFormatException | IndexOutOfBoundsException e) { 272 invalidManifestEntries.add(key); 269 273 Logging.error(e); 270 274 } -
trunk/test/unit/org/openstreetmap/josm/plugins/PluginHandlerTestIT.java
r13793 r13993 55 55 .collect(Collectors.toMap(e -> e.getKey(), e -> ExceptionUtils.getRootCause(e.getValue()))); 56 56 57 List<PluginInformation> loadedPlugins = PluginHandler.getPlugins(); 58 Map<String, List<String>> invalidManifestEntries = loadedPlugins.stream().filter(pi -> !pi.invalidManifestEntries.isEmpty()) 59 .collect(Collectors.toMap(pi -> pi.name, pi -> pi.invalidManifestEntries)); 60 57 61 // Add/remove layers twice to test basic plugin good behaviour 58 62 Map<String, Throwable> layerExceptions = new HashMap<>(); 59 List<PluginInformation> loadedPlugins = PluginHandler.getPlugins();60 63 for (int i = 0; i < 2; i++) { 61 64 OsmDataLayer layer = new OsmDataLayer(new DataSet(), "Layer "+i, null); … … 69 72 } 70 73 74 MapUtils.debugPrint(System.out, null, invalidManifestEntries); 71 75 MapUtils.debugPrint(System.out, null, loadingExceptions); 72 76 MapUtils.debugPrint(System.out, null, layerExceptions); 73 String msg = Arrays.toString(loadingExceptions.entrySet().toArray()) + '\n' + 77 String msg = Arrays.toString(invalidManifestEntries.entrySet().toArray()) + '\n' + 78 Arrays.toString(loadingExceptions.entrySet().toArray()) + '\n' + 74 79 Arrays.toString(layerExceptions.entrySet().toArray()); 75 assertTrue(msg, loadingExceptions.isEmpty() && layerExceptions.isEmpty());80 assertTrue(msg, invalidManifestEntries.isEmpty() && loadingExceptions.isEmpty() && layerExceptions.isEmpty()); 76 81 } 77 82
Note:
See TracChangeset
for help on using the changeset viewer.