Debian Codegraph @

bundles/org.eclipse.equinox.p2.updatesite/src/org/eclipse/equinox/internal/p2/updatesite/RemoteFeaturesAction.java

raw
1 /*******************************************************************************
2 * Copyright (c) 2008, 2011 Code 9 and others.
3 *
4 * This
5 * program and the accompanying materials are made available under the terms of
6 * the Eclipse Public License 2.0 which accompanies this distribution, and is
7 * available at
8 * https://www.eclipse.org/legal/epl-2.0/
9 *
10 * SPDX-License-Identifier: EPL-2.0
11 *
12 * Contributors:
13 * Code 9 - initial API and implementation
14 * IBM - ongoing development
15 ******************************************************************************/
16 package org.eclipse.equinox.internal.p2.updatesite;
17
18 import java.util.*;
19 import org.eclipse.core.runtime.*;
20 import org.eclipse.equinox.p2.core.ProvisionException;
21 import org.eclipse.equinox.p2.metadata.IArtifactKey;
22 import org.eclipse.equinox.p2.metadata.IInstallableUnit;
23 import org.eclipse.equinox.p2.publisher.*;
24 import org.eclipse.equinox.p2.publisher.eclipse.*;
25 import org.eclipse.osgi.service.resolver.BundleDescription;
26 import org.eclipse.osgi.util.NLS;
27
28 public class RemoteFeaturesAction extends FeaturesAction {
29 private UpdateSite updateSite;
30
31 public RemoteFeaturesAction(UpdateSite updateSite) {
32 super((Feature[]) null);
33 this.updateSite = updateSite;
34 }
35
36 public RemoteFeaturesAction(Feature[] features) {
37 super(features);
38 throw new IllegalArgumentException();
39 }
40
41 @Override
42 public IStatus perform(IPublisherInfo publisherInfo, IPublisherResult results, IProgressMonitor monitor) {
43 try {
44 this.info = publisherInfo;
45 features = updateSite.loadFeatures(monitor);
46 return super.perform(publisherInfo, results, monitor);
47 } catch (ProvisionException e) {
48 return new Status(IStatus.ERROR, Activator.ID, NLS.bind(Messages.Error_Generation, updateSite), e);
49 } catch (OperationCanceledException e) {
50 return Status.CANCEL_STATUS;
51 }
52
53 }
54
55 @Override
56 protected void generateFeatureIUs(Feature[] featureList, IPublisherResult result) {
57 Map<String, String> extraProperties = new HashMap<>();
58 extraProperties.put(IInstallableUnit.PROP_PARTIAL_IU, Boolean.TRUE.toString());
59 for (Feature feature : featureList) {
60 FeatureEntry[] featureEntries = feature.getEntries();
61 for (FeatureEntry entry : featureEntries) {
62 if (entry.isPlugin() && !entry.isRequires()) {
63 Dictionary<String, String> mockManifest = new Hashtable<>();
64 mockManifest.put("Manifest-Version", "1.0"); //$NON-NLS-1$ //$NON-NLS-2$
65 mockManifest.put("Bundle-ManifestVersion", "2"); //$NON-NLS-1$ //$NON-NLS-2$
66 mockManifest.put("Bundle-SymbolicName", entry.getId()); //$NON-NLS-1$
67 mockManifest.put("Bundle-Version", entry.getVersion()); //$NON-NLS-1$
68 BundleDescription bundleDescription = BundlesAction.createBundleDescription(mockManifest, null);
69 IArtifactKey key = BundlesAction.createBundleArtifactKey(entry.getId(), entry.getVersion());
70 IInstallableUnit[] bundleIUs = EclipsePublisherHelper.createEclipseIU(bundleDescription, entry.isUnpack(), key, extraProperties);
71 for (IInstallableUnit bundleIU : bundleIUs) {
72 result.addIU(bundleIU, IPublisherResult.ROOT);
73 }
74 }
75 }
76 IInstallableUnit featureIU = createFeatureJarIU(feature, new PublisherInfo());
77 List<IInstallableUnit> childIUs = new ArrayList<>();
78 childIUs.add(featureIU);
79 IInstallableUnit groupIU = createGroupIU(feature, childIUs, new PublisherInfo());
80 result.addIU(featureIU, IPublisherResult.ROOT);
81 result.addIU(groupIU, IPublisherResult.ROOT);
82 generateSiteReferences(feature, result, info);
83 }
84 }
85 }