Révision 3153
tmp/org.txm.rcp/src/main/java/org/txm/rcp/p2/plugins/TXMUpdateHandler.java (revision 3153) | ||
---|---|---|
1 | 1 |
package org.txm.rcp.p2.plugins; |
2 | 2 |
|
3 |
import static java.lang.System.setErr; |
|
4 |
import static java.util.prefs.Preferences.systemRoot; |
|
5 |
|
|
3 | 6 |
import java.io.BufferedReader; |
4 | 7 |
import java.io.BufferedWriter; |
5 | 8 |
import java.io.File; |
... | ... | |
20 | 23 |
import java.util.prefs.Preferences; |
21 | 24 |
|
22 | 25 |
import org.eclipse.core.commands.ExecutionEvent; |
23 |
import org.eclipse.core.runtime.Assert; |
|
24 |
import org.eclipse.core.runtime.IProgressMonitor; |
|
25 |
import org.eclipse.core.runtime.IStatus; |
|
26 |
import org.eclipse.core.runtime.OperationCanceledException; |
|
27 | 26 |
import org.eclipse.equinox.internal.p2.engine.Profile; |
28 | 27 |
import org.eclipse.equinox.internal.p2.engine.SimpleProfileRegistry; |
29 |
import org.eclipse.equinox.internal.p2.metadata.InstallableUnit; |
|
30 |
import org.eclipse.equinox.internal.p2.ui.sdk.ProvSDKMessages; |
|
31 | 28 |
import org.eclipse.equinox.internal.p2.ui.sdk.UpdateHandler; |
32 | 29 |
import org.eclipse.equinox.p2.core.IProvisioningAgent; |
33 | 30 |
import org.eclipse.equinox.p2.core.ProvisionException; |
34 | 31 |
import org.eclipse.equinox.p2.engine.IProfile; |
35 | 32 |
import org.eclipse.equinox.p2.engine.IProfileRegistry; |
36 | 33 |
import org.eclipse.equinox.p2.metadata.IInstallableUnit; |
37 |
import org.eclipse.equinox.p2.operations.ProfileChangeOperation; |
|
38 |
import org.eclipse.equinox.p2.operations.RepositoryTracker; |
|
39 |
import org.eclipse.equinox.p2.operations.UpdateOperation; |
|
40 | 34 |
import org.eclipse.equinox.p2.repository.artifact.IArtifactRepositoryManager; |
41 | 35 |
import org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager; |
42 |
import org.eclipse.equinox.p2.ui.LoadMetadataRepositoryJob; |
|
43 | 36 |
import org.eclipse.equinox.p2.ui.ProvisioningUI; |
44 | 37 |
import org.eclipse.osgi.util.NLS; |
45 | 38 |
import org.eclipse.swt.SWT; |
46 | 39 |
import org.eclipse.swt.widgets.Display; |
47 |
import org.eclipse.swt.widgets.MessageBox; |
|
48 | 40 |
import org.eclipse.swt.widgets.Shell; |
49 | 41 |
import org.eclipse.ui.handlers.HandlerUtil; |
50 |
import org.eclipse.ui.statushandlers.StatusManager; |
|
51 | 42 |
import org.osgi.framework.Version; |
52 | 43 |
import org.txm.core.preferences.TBXPreferences; |
53 | 44 |
import org.txm.rcp.Activator; |
... | ... | |
59 | 50 |
import org.txm.utils.logger.Log; |
60 | 51 |
import org.txm.utils.zip.GZip; |
61 | 52 |
|
62 |
import static java.lang.System.setErr; |
|
63 |
import static java.util.prefs.Preferences.systemRoot; |
|
64 |
|
|
65 | 53 |
public class TXMUpdateHandler extends UpdateHandler { |
66 | 54 |
|
67 | 55 |
public static final String ID = "org.txm.rcp.p2.plugins.TXMUpdateHandler"; |
... | ... | |
93 | 81 |
} |
94 | 82 |
} |
95 | 83 |
catch (Exception e) { |
96 |
// TODO Auto-generated catch block |
|
97 | 84 |
e.printStackTrace(); |
98 | 85 |
} |
99 | 86 |
} |
... | ... | |
231 | 218 |
location = new URL(path); |
232 | 219 |
} |
233 | 220 |
catch (MalformedURLException e) { |
234 |
Log.severe(NLS.bind(TXMUIMessages.switchLanguageColonMalformedUrlColonP0, location));
|
|
221 |
Log.warning(NLS.bind(TXMUIMessages.switchLanguageColonMalformedUrlColonP0, location));
|
|
235 | 222 |
return false; |
236 | 223 |
} |
237 | 224 |
|
... | ... | |
244 | 231 |
// System.out.println(profileDir); |
245 | 232 |
|
246 | 233 |
if (!profileDir.exists()) { |
247 |
Log.severe("p2 profile directory does not exists: " + profileDir);
|
|
234 |
Log.warning("p2 profile directory does not exists: " + profileDir);
|
|
248 | 235 |
return false; |
249 | 236 |
} |
250 | 237 |
|
... | ... | |
262 | 249 |
patchProfile(profileXMLFile); |
263 | 250 |
// 4- delete old gz profile |
264 | 251 |
if (!gzFile.delete()) { |
265 |
Log.severe("Could not delete old profile GZfile: " + gzFile);
|
|
252 |
Log.warning("Could not delete old profile GZfile: " + gzFile);
|
|
266 | 253 |
return false; |
267 | 254 |
} |
268 | 255 |
|
... | ... | |
273 | 260 |
GZip.compress(profileXMLFile, gzFile); |
274 | 261 |
// 6- clean files |
275 | 262 |
if (!profileXMLFile.delete()) { |
276 |
Log.severe("Could not delete temporary profile XML file: " + profileXMLFile);
|
|
263 |
Log.warning("Could not delete temporary profile XML file: " + profileXMLFile);
|
|
277 | 264 |
return false; |
278 | 265 |
} |
279 | 266 |
Log.fine("Profile archive patched: " + gzFile); |
280 | 267 |
return true; |
281 | 268 |
} |
282 | 269 |
catch (IOException e) { |
283 |
Log.severe("Failed to fix profile file: " + e);
|
|
270 |
Log.warning("Failed to fix profile file: " + e);
|
|
284 | 271 |
Log.printStackTrace(e); |
285 | 272 |
return false; |
286 | 273 |
} |
... | ... | |
299 | 286 |
// addURL(agent, repoKepler); |
300 | 287 |
} |
301 | 288 |
catch (Exception e) { |
302 |
Log.severe("Could not add update default repository: " + uriDefault);
|
|
289 |
Log.warning("Could not add update default repository: " + uriDefault);
|
|
303 | 290 |
Log.printStackTrace(e); |
304 | 291 |
} |
305 | 292 |
|
... | ... | |
329 | 316 |
} |
330 | 317 |
} |
331 | 318 |
catch (Exception e) { |
332 |
Log.severe("Could not add update DEV repository: " + uriDev);
|
|
319 |
Log.warning("Could not add update DEV repository: " + uriDev);
|
|
333 | 320 |
e.printStackTrace(); |
334 | 321 |
} |
335 | 322 |
|
... | ... | |
344 | 331 |
} |
345 | 332 |
} |
346 | 333 |
catch (Exception e) { |
347 |
Log.severe("Could not add update ALPHA repository: " + uriAlpha);
|
|
334 |
Log.warning("Could not add update ALPHA repository: " + uriAlpha);
|
|
348 | 335 |
e.printStackTrace(); |
349 | 336 |
} |
350 | 337 |
|
... | ... | |
359 | 346 |
} |
360 | 347 |
} |
361 | 348 |
catch (Exception e) { |
362 |
Log.severe("Can not add update BETA repository: " + uriBeta);
|
|
349 |
Log.warning("Can not add update BETA repository: " + uriBeta);
|
|
363 | 350 |
} |
364 | 351 |
} |
365 | 352 |
|
... | ... | |
376 | 363 |
// addURL(agent, repoKepler); |
377 | 364 |
} |
378 | 365 |
catch (Exception e) { |
379 |
Log.severe("Could not add update default repository: " + uriDefault);
|
|
366 |
Log.warning("Could not add update default repository: " + uriDefault);
|
|
380 | 367 |
Log.printStackTrace(e); |
381 | 368 |
} |
382 | 369 |
|
... | ... | |
406 | 393 |
} |
407 | 394 |
} |
408 | 395 |
catch (Exception e) { |
409 |
Log.severe("Could not add update DEV repository: " + uriDev);
|
|
396 |
Log.warning("Could not add update DEV repository: " + uriDev);
|
|
410 | 397 |
e.printStackTrace(); |
411 | 398 |
} |
412 | 399 |
|
... | ... | |
421 | 408 |
} |
422 | 409 |
} |
423 | 410 |
catch (Exception e) { |
424 |
Log.severe("Could not add update ALPHA repository: " + uriAlpha);
|
|
411 |
Log.warning("Could not add update ALPHA repository: " + uriAlpha);
|
|
425 | 412 |
e.printStackTrace(); |
426 | 413 |
} |
427 | 414 |
|
... | ... | |
436 | 423 |
} |
437 | 424 |
} |
438 | 425 |
catch (Exception e) { |
439 |
Log.severe("Can not add update BETA repository: " + uriBeta);
|
|
426 |
Log.warning("Can not add update BETA repository: " + uriBeta);
|
|
440 | 427 |
} |
441 | 428 |
|
442 | 429 |
} |
... | ... | |
463 | 450 |
manager.loadRepository(location, null); |
464 | 451 |
} |
465 | 452 |
catch (Exception e) { |
466 |
Log.severe("No repo - create a newmetadata repo");
|
|
453 |
Log.warning("No repo - create a newmetadata repo");
|
|
467 | 454 |
// for convenience create and add a repository here |
468 | 455 |
String repositoryName = location + " - metadata"; |
469 | 456 |
try { |
470 |
manager.createRepository(location, repositoryName, IMetadataRepositoryManager.TYPE_SIMPLE_REPOSITORY, |
|
471 |
null); |
|
457 |
manager.createRepository(location, repositoryName, IMetadataRepositoryManager.TYPE_SIMPLE_REPOSITORY, null); |
|
472 | 458 |
} |
473 | 459 |
catch (ProvisionException e2) { |
474 | 460 |
Log.severe("Error while adding metadata repo: " + location); |
Formats disponibles : Unified diff