private static String[] getRunModes(final org.apache.sling.feature.Artifact bundle) { String runMode = bundle.getMetadata().get("run-modes"); String[] runModes; if (runMode != null) { runModes = runMode.split(","); } else { runModes = null; } return runModes; } }
/** * Create a copy of the artifact with a different id * * @param id The new id * @return The copy of the feature with the new id */ public Artifact copy(final ArtifactId id) { final Artifact result = new Artifact(id); result.getMetadata().putAll(this.getMetadata()); return result; }
/** * Set the start order of the artifact * This is a convenience method which sets the value of the property named * {@code #KEY_START_ORDER} from the metadata. * @param startOrder The start order * @throws IllegalArgumentException If the number is negative */ public void setStartOrder(final int startOrder) { if ( startOrder < 0 ) { throw new IllegalArgumentException("Start order must be >= 0 but is " + startOrder); } if ( startOrder == 0 ) { this.getMetadata().remove(KEY_START_ORDER); } else { this.getMetadata().put(KEY_START_ORDER, String.valueOf(startOrder)); } }
/** * Get the start order of the artifact. * This is a convenience method which gets the value for the property named * {@code #KEY_START_ORDER} from the metadata. * @return The start order, if no start order is defined, {@code 0} is returned. * @throws NumberFormatException If the stored metadata is not a number * @throws IllegalStateException If the stored metadata is a negative number */ public int getStartOrder() { final String order = this.getMetadata().get(Artifact.KEY_START_ORDER); final int startOrder; if ( order != null ) { startOrder = Integer.parseInt(order); if ( startOrder < 0 ) { throw new IllegalStateException("Start order must be >= 0 but is " + order); } } else { startOrder = 0; } return startOrder; }
/** * Obtain the alias or aliases for the artifact. * @param includeMain Whether to include the main ID in the result. * @return The aliases or an empty set if there are none. */ public Set<ArtifactId> getAliases(boolean includeMain) { Set<ArtifactId> artifactIds = new HashSet<>(); if (includeMain) artifactIds.add(getId()); String aliases = getMetadata().get(KEY_ALIAS); if (aliases != null) { for (String alias : aliases.split(",")) { alias = alias.trim(); if (alias.indexOf(':') == alias.lastIndexOf(':')) { // No version provided, set to version zero alias += ":0.0.0"; } artifactIds.add(ArtifactId.fromMvnId(alias)); } } return artifactIds; }
protected void analyze() throws IOException { final String name = this.manifest.getMainAttributes().getValue(Constants.BUNDLE_SYMBOLICNAME); if ( name != null ) { final String version = this.manifest.getMainAttributes().getValue(Constants.BUNDLE_VERSION); if ( version == null ) { throw new IOException("Unable to get bundle version from artifact " + getArtifact().getId().toMvnId()); } this.symbolicName = name; this.bundleVersion = version; final String newBundleName = this.getArtifact().getMetadata().get("bundle:rename-bsn"); if (newBundleName != null) { this.symbolicName = newBundleName; } this.getExportedPackages().addAll(extractExportedPackages(this.manifest)); this.getImportedPackages().addAll(extractImportedPackages(this.manifest)); this.getDynamicImportedPackages().addAll(extractDynamicImportedPackages(this.manifest)); try { ResourceImpl resource = ResourceBuilder.build(null, this.manifest.getMainAttributes().entrySet().stream() .collect(Collectors.toMap(entry -> entry.getKey().toString(), entry -> entry.getValue().toString()))); this.getCapabilities().addAll(resource.getCapabilities(null)); this.getRequirements().addAll(resource.getRequirements(null)); } catch (Exception ex) { throw new IOException(ex); } } else { throw new IOException("Unable to get bundle symbolic name from artifact " + getArtifact().getId().toMvnId()); } }
bundle.getMetadata().put("content-package", cp.getArtifact().getId().toMvnId()); bundle.getMetadata().put("content-path", contentPath);
if (sourceFeature.getId().toMvnId().equals(existing.getMetadata().get(originKey))) { if (sourceFeature != null && source.contains(sa) && sa.getMetadata().get(originKey) == null) { cp.getMetadata().put(originKey, sourceFeature.getId().toMvnId());
newArtifact.getMetadata().put(entry.getKey(), entry.getValue()); newArtifact.getMetadata().put("start-level", String.valueOf(startLevel));
final Artifact newBundle = new Artifact(id.getGroupId(), id.getArtifactId(), id.getVersion(), id.getClassifier(), id.getType()); Object configs = bundle.getMetadata().get("configurations"); if (configs instanceof List) { for (Object config : (List<?>) configs) { for(final Map.Entry<String, String> prop : bundle.getMetadata().entrySet()) { switch (prop.getKey()) { String sl = bundle.getMetadata().get("start-level"); final ArtifactId id = cp.getId(); final Artifact newCP = new Artifact(id.getGroupId(), id.getArtifactId(), id.getVersion(), id.getClassifier(), id.getType()); for(final Map.Entry<String, String> prop : cp.getMetadata().entrySet()) { if (prop.getKey().equals("runmodes")) { if (extRunModes == null) {
if (sourceFeature.getId().toMvnId().equals(existing.getMetadata().get(originKey))) { && sa.getMetadata().get(originKey) == null) { cp.getMetadata().put(originKey, sourceFeature.getId().toMvnId());
a.getMetadata().remove(TRACKING_KEY); a.getMetadata().remove(TRACKING_KEY);