protected void addCapability(List<IProvidedCapability> caps, GenericDescription provideCapDesc, InstallableUnitDescription iu, int capNo) { // Convert the values to String, Version, List of String or Version Map<String, Object> capAttrs = provideCapDesc.getDeclaredAttributes().entrySet().stream().collect(toMap(Entry::getKey, e -> convertAttribute(e.getValue()))); // Resolve the namespace String capNs = provideCapDesc.getType(); // Resolve the mandatory p2 name // By convention OSGi capabilities have an attribute named like the capability namespace. // If this is not the case synthesize a unique name (e.g. "osgi.service" has an "objectClass" attribute instead). // TODO If present but not a String log a warning somehow that it is ignored? Or fail the publication? capAttrs.compute(capNs, (k, v) -> (v instanceof String) ? v : String.format("%s_%s-%s", iu.getId(), iu.getVersion(), capNo)); //$NON-NLS-1$ // Resolve the mandatory p2 version // By convention versioned OSGi capabilities have a "version" attribute containing the OSGi Version object // If this is not the case use an empty version (e.g. "osgi.ee" has a list of versions). // TODO If present but not a Version log a warning somehow that it is ignored? Or fail the publication? capAttrs.compute(IProvidedCapability.PROPERTY_VERSION, (k, v) -> (v instanceof Version) ? v : Version.emptyVersion); caps.add(MetadataFactory.createProvidedCapability(capNs, capAttrs)); }
/** * Add all of the advised IU properties for the given IU. * @param iu the IU to decorate * @param info the publisher info supplying the advice */ protected static void processInstallableUnitPropertiesAdvice(InstallableUnitDescription iu, IPublisherInfo info) { Collection<IPropertyAdvice> advice = info.getAdvice(null, false, iu.getId(), iu.getVersion(), IPropertyAdvice.class); for (IPropertyAdvice entry : advice) { Map<String, String> props = entry.getInstallableUnitProperties(iu); if (props == null) continue; for (Entry<String, String> pe : props.entrySet()) { iu.setProperty(pe.getKey(), pe.getValue()); } } }
protected static void processLicense(InstallableUnitDescription iu, IPublisherInfo info) { Collection<ILicenseAdvice> advice = info.getAdvice(null, true, iu.getId(), iu.getVersion(), ILicenseAdvice.class); if (advice.size() > 0) { // Only process the first license we find for this IU. ILicenseAdvice entry = advice.iterator().next(); String licenseText = entry.getLicenseText() == null ? "" : entry.getLicenseText(); //$NON-NLS-1$ String licenseUrl = entry.getLicenseURL() == null ? "" : entry.getLicenseURL(); //$NON-NLS-1$ if (licenseText.length() > 0 || licenseUrl.length() > 0) iu.setLicenses(new ILicense[] {MetadataFactory.createLicense(toURIOrNull(licenseUrl), licenseText)}); } }
/** * Add any update descriptor advice to the given IU * @param iu the IU to decorate * @param info the publisher info supplying the advice */ protected static void processUpdateDescriptorAdvice(InstallableUnitDescription iu, IPublisherInfo info) { Collection<IUpdateDescriptorAdvice> advice = info.getAdvice(null, false, iu.getId(), iu.getVersion(), IUpdateDescriptorAdvice.class); if (advice.isEmpty()) return; for (IUpdateDescriptorAdvice entry : advice) { //process the IU Descriptor IUpdateDescriptor updateDescriptor = entry.getUpdateDescriptor(iu); if (updateDescriptor != null) { iu.setUpdateDescriptor(updateDescriptor); } } }
/** * Add all of the advised IU properties for the given IU. * @param iu the IU to decorate * @param info the publisher info supplying the advice */ protected static void processInstallableUnitPropertiesAdvice(InstallableUnitDescription iu, IPublisherInfo info) { Collection<IPropertyAdvice> advice = info.getAdvice(null, false, iu.getId(), iu.getVersion(), IPropertyAdvice.class); for (IPropertyAdvice entry : advice) { Map<String, String> props = entry.getInstallableUnitProperties(iu); if (props == null) continue; for (Entry<String, String> pe : props.entrySet()) { iu.setProperty(pe.getKey(), pe.getValue()); } } }
/** * Add all of the advised IU properties for the given IU. * @param iu the IU to decorate * @param info the publisher info supplying the advice */ protected static void processInstallableUnitPropertiesAdvice(InstallableUnitDescription iu, IPublisherInfo info) { Collection<IPropertyAdvice> advice = info.getAdvice(null, false, iu.getId(), iu.getVersion(), IPropertyAdvice.class); for (IPropertyAdvice entry : advice) { Map<String, String> props = entry.getInstallableUnitProperties(iu); if (props == null) continue; for (Entry<String, String> pe : props.entrySet()) { iu.setProperty(pe.getKey(), pe.getValue()); } } }
/** * Add all of the advised IU properties for the given IU. * @param iu the IU to decorate * @param info the publisher info supplying the advice */ protected static void processInstallableUnitPropertiesAdvice(InstallableUnitDescription iu, IPublisherInfo info) { Collection<IPropertyAdvice> advice = info.getAdvice(null, false, iu.getId(), iu.getVersion(), IPropertyAdvice.class); for (IPropertyAdvice entry : advice) { Map<String, String> props = entry.getInstallableUnitProperties(iu); if (props == null) continue; for (Entry<String, String> pe : props.entrySet()) { iu.setProperty(pe.getKey(), pe.getValue()); } } }
/** * Add any update descriptor advice to the given IU * @param iu the IU to decorate * @param info the publisher info supplying the advice */ protected static void processUpdateDescriptorAdvice(InstallableUnitDescription iu, IPublisherInfo info) { Collection<IUpdateDescriptorAdvice> advice = info.getAdvice(null, false, iu.getId(), iu.getVersion(), IUpdateDescriptorAdvice.class); if (advice.isEmpty()) return; for (IUpdateDescriptorAdvice entry : advice) { //process the IU Descriptor IUpdateDescriptor updateDescriptor = entry.getUpdateDescriptor(iu); if (updateDescriptor != null) { iu.setUpdateDescriptor(updateDescriptor); } } }
protected static void processTouchpointAdvice(InstallableUnitDescription iu, Map<String, ? extends Object> currentInstructions, IPublisherInfo info, String configSpec) { Collection<ITouchpointAdvice> advice = info.getAdvice(configSpec, false, iu.getId(), iu.getVersion(), ITouchpointAdvice.class); if (currentInstructions == null) { if (advice == null || advice.isEmpty()) return; currentInstructions = CollectionUtils.emptyMap(); } ITouchpointData result = MetadataFactory.createTouchpointData(currentInstructions); if (advice != null) { for (ITouchpointAdvice entry : advice) { result = entry.getTouchpointData(result); } } iu.addTouchpointData(result); }
protected static void processTouchpointAdvice(InstallableUnitDescription iu, Map<String, ? extends Object> currentInstructions, IPublisherInfo info, String configSpec) { Collection<ITouchpointAdvice> advice = info.getAdvice(configSpec, false, iu.getId(), iu.getVersion(), ITouchpointAdvice.class); if (currentInstructions == null) { if (advice == null || advice.isEmpty()) return; currentInstructions = Collections.emptyMap(); } ITouchpointData result = MetadataFactory.createTouchpointData(currentInstructions); if (advice != null) { for (ITouchpointAdvice entry : advice) { result = entry.getTouchpointData(result); } } iu.addTouchpointData(result); }
protected static void processTouchpointAdvice(InstallableUnitDescription iu, Map<String, ? extends Object> currentInstructions, IPublisherInfo info, String configSpec) { Collection<ITouchpointAdvice> advice = info.getAdvice(configSpec, false, iu.getId(), iu.getVersion(), ITouchpointAdvice.class); if (currentInstructions == null) { if (advice == null || advice.isEmpty()) return; currentInstructions = Collections.emptyMap(); } ITouchpointData result = MetadataFactory.createTouchpointData(currentInstructions); if (advice != null) { for (ITouchpointAdvice entry : advice) { result = entry.getTouchpointData(result); } } iu.addTouchpointData(result); }
protected void addSelfCapability(InstallableUnitDescription root) { root.setCapabilities(new IProvidedCapability[] {createSelfCapability(root.getId(), root.getVersion())}); }
protected void addSelfCapability(InstallableUnitDescription root) { root.setCapabilities(new IProvidedCapability[] {createSelfCapability(root.getId(), root.getVersion())}); }
protected void addSelfCapability(InstallableUnitDescription root) { root.setCapabilities(new IProvidedCapability[] {createSelfCapability(root.getId(), root.getVersion())}); }
private void ensureSelfCapability(InstallableUnitDescription iu) { Collection<IProvidedCapability> capabilities = iu.getProvidedCapabilities(); for (IProvidedCapability capability : capabilities) { if (IInstallableUnit.NAMESPACE_IU_ID.equals(capability.getNamespace()) && iu.getId().equals(capability.getName()) && iu.getVersion().equals(capability.getVersion())) { return; } } IProvidedCapability[] newCapabilities = new IProvidedCapability[capabilities.size() + 1]; capabilities.toArray(newCapabilities); newCapabilities[newCapabilities.length - 1] = createSelfCapability(iu.getId(), iu.getVersion()); iu.setCapabilities(newCapabilities); } }
protected static void processTouchpointAdvice(InstallableUnitDescription iu, Map<String, ? extends Object> currentInstructions, IPublisherInfo info, String configSpec) { Collection<ITouchpointAdvice> advice = info.getAdvice(configSpec, false, iu.getId(), iu.getVersion(), ITouchpointAdvice.class); if (currentInstructions == null) { if (advice == null || advice.isEmpty()) return; currentInstructions = Collections.emptyMap(); } ITouchpointData result = MetadataFactory.createTouchpointData(currentInstructions); if (advice != null) { for (ITouchpointAdvice entry : advice) { result = entry.getTouchpointData(result); } } iu.addTouchpointData(result); }
protected static void processLicense(InstallableUnitDescription iu, IPublisherInfo info) { Collection<ILicenseAdvice> advice = info.getAdvice(null, true, iu.getId(), iu.getVersion(), ILicenseAdvice.class); if (advice.size() > 0) { // Only process the first license we find for this IU. ILicenseAdvice entry = advice.iterator().next(); String licenseText = entry.getLicenseText() == null ? "" : entry.getLicenseText(); //$NON-NLS-1$ String licenseUrl = entry.getLicenseURL() == null ? "" : entry.getLicenseURL(); //$NON-NLS-1$ if (licenseText.length() > 0 || licenseUrl.length() > 0) iu.setLicenses(new ILicense[] {MetadataFactory.createLicense(toURIOrNull(licenseUrl), licenseText)}); } }
protected static void processLicense(InstallableUnitDescription iu, IPublisherInfo info) { Collection<ILicenseAdvice> advice = info.getAdvice(null, true, iu.getId(), iu.getVersion(), ILicenseAdvice.class); if (advice.size() > 0) { // Only process the first license we find for this IU. ILicenseAdvice entry = advice.iterator().next(); String licenseText = entry.getLicenseText() == null ? "" : entry.getLicenseText(); //$NON-NLS-1$ String licenseUrl = entry.getLicenseURL() == null ? "" : entry.getLicenseURL(); //$NON-NLS-1$ if (licenseText.length() > 0 || licenseUrl.length() > 0) iu.setLicenses(new ILicense[] {MetadataFactory.createLicense(toURIOrNull(licenseUrl), licenseText)}); } }
protected static void processLicense(InstallableUnitDescription iu, IPublisherInfo info) { Collection<ILicenseAdvice> advice = info.getAdvice(null, true, iu.getId(), iu.getVersion(), ILicenseAdvice.class); if (advice.size() > 0) { // Only process the first license we find for this IU. ILicenseAdvice entry = advice.iterator().next(); String licenseText = entry.getLicenseText() == null ? "" : entry.getLicenseText(); //$NON-NLS-1$ String licenseUrl = entry.getLicenseURL() == null ? "" : entry.getLicenseURL(); //$NON-NLS-1$ if (licenseText.length() > 0 || licenseUrl.length() > 0) iu.setLicenses(new ILicense[] {MetadataFactory.createLicense(toURIOrNull(licenseUrl), licenseText)}); } }
protected void addSelfCapability(InstallableUnitDescription root) { root.setCapabilities(new IProvidedCapability[] {createSelfCapability(root.getId(), root.getVersion())}); }