Revision 0d2d1f78
Added by Cherian Mathew over 8 years ago
eu.etaxonomy.taxeditor.application/src/main/java/eu/etaxonomy/taxeditor/update/P2Util.java | ||
---|---|---|
7 | 7 |
|
8 | 8 |
import org.eclipse.core.runtime.IProgressMonitor; |
9 | 9 |
import org.eclipse.core.runtime.IStatus; |
10 |
import org.eclipse.core.runtime.NullProgressMonitor; |
|
11 | 10 |
import org.eclipse.core.runtime.OperationCanceledException; |
12 | 11 |
import org.eclipse.core.runtime.Status; |
13 | 12 |
import org.eclipse.core.runtime.jobs.IJobChangeEvent; |
... | ... | |
16 | 15 |
import org.eclipse.equinox.internal.p2.ui.ProvUI; |
17 | 16 |
import org.eclipse.equinox.internal.p2.ui.model.ElementUtils; |
18 | 17 |
import org.eclipse.equinox.internal.p2.ui.model.MetadataRepositoryElement; |
19 |
import org.eclipse.equinox.p2.repository.IRepository; |
|
20 |
import org.eclipse.equinox.p2.repository.IRepositoryManager; |
|
21 |
import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository; |
|
22 |
import org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager; |
|
23 | 18 |
import org.eclipse.equinox.p2.core.IProvisioningAgent; |
24 | 19 |
import org.eclipse.equinox.p2.core.ProvisionException; |
25 | 20 |
import org.eclipse.equinox.p2.operations.ProvisioningJob; |
26 | 21 |
import org.eclipse.equinox.p2.operations.ProvisioningSession; |
27 |
import org.eclipse.equinox.p2.operations.RepositoryTracker; |
|
28 | 22 |
import org.eclipse.equinox.p2.operations.Update; |
29 | 23 |
import org.eclipse.equinox.p2.operations.UpdateOperation; |
24 |
import org.eclipse.equinox.p2.repository.IRepository; |
|
25 |
import org.eclipse.equinox.p2.repository.IRepositoryManager; |
|
26 |
import org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager; |
|
30 | 27 |
import org.eclipse.equinox.p2.ui.ProvisioningUI; |
31 | 28 |
import org.eclipse.swt.widgets.Display; |
32 | 29 |
import org.eclipse.ui.PlatformUI; |
... | ... | |
146 | 143 |
* |
147 | 144 |
*/ |
148 | 145 |
public static void checkForUpdates() { |
149 |
// the main job which performs the update |
|
146 |
|
|
150 | 147 |
Job updateJob = new Job("Update Job") { |
151 | 148 |
@Override |
152 | 149 |
public IStatus run(IProgressMonitor monitor) { |
... | ... | |
162 | 159 |
*/ |
163 | 160 |
private static IStatus doCheckForUpdates(IProgressMonitor monitor) { |
164 | 161 |
|
162 |
// force refresh all the caches before |
|
163 |
IMetadataRepositoryManager metaManager = ProvUI.getMetadataRepositoryManager(ProvisioningUI.getDefaultUI().getSession()); |
|
164 |
URI[] repos = metaManager.getKnownRepositories(IRepositoryManager.REPOSITORIES_ALL); |
|
165 |
for(URI repo : repos) { |
|
166 |
try { |
|
167 |
metaManager.refreshRepository(repo, monitor); |
|
168 |
} catch (ProvisionException pe) { |
|
169 |
IStatus errorStatus = new Status(IStatus.ERROR, TaxonomicEditorPlugin.PLUGIN_ID, |
|
170 |
"Error occured while reloading cache.", pe); |
|
171 |
|
|
172 |
} catch (OperationCanceledException oce) { |
|
173 |
IStatus errorStatus = new Status(IStatus.ERROR, TaxonomicEditorPlugin.PLUGIN_ID, |
|
174 |
"Error occured while reloading cache.", oce); |
|
175 |
} |
|
176 |
} |
|
165 | 177 |
BundleContext bundleContext = TaxonomicEditorPlugin.getContext(); |
166 | 178 |
ServiceReference reference = bundleContext.getServiceReference(IProvisioningAgent.SERVICE_NAME); |
167 | 179 |
if (reference == null) { |
Also available in: Unified diff
#5061 Add force refresh of p2 repositories before checking for updates