public static void convert(File inputFile, File outputFile, FeatureProvider fp, File ... additionalInputFiles) throws UncheckedIOException { if (outputFile.exists()) { if (outputFile.lastModified() > inputFile.lastModified()) { LOGGER.debug("Skipping the generation of {} as this file already exists and is newer.", outputFile); return; } } org.apache.sling.feature.Feature feature = getFeature(inputFile); if (feature.getPrototype() != null) { feature = handlePrototype(feature, additionalInputFiles, fp); } Object featureNameVar = feature.getVariables().remove(PROVISIONING_MODEL_NAME_VARIABLE); String featureName; if (featureNameVar instanceof String) { featureName = (String) featureNameVar; } else { featureName = feature.getId().getArtifactId(); } String runMode = feature.getVariables().remove(PROVISIONING_RUNMODES); String[] runModes = null; if (runMode != null) { runModes = runMode.split(","); } Feature newFeature = new Feature(featureName); convert(newFeature, feature.getVariables(), feature.getBundles(), feature.getConfigurations(), feature.getFrameworkProperties(), feature.getExtensions(), outputFile.getAbsolutePath(), runModes); }
/** * Scan a feature * * @param feature The feature * @return The feature descriptor * @throws IOException If something goes wrong or a scanner is missing */ public FeatureDescriptor scan(final Feature feature) throws IOException { final FeatureDescriptorImpl desc = new FeatureDescriptorImpl(feature); getBundleInfos(feature.getBundles(), desc); scan(feature, feature.getExtensions(), desc); compact(desc); desc.lock(); return desc; }
final List<String> artifactOverrides, final String originKey) { for(final Extension ext : source.getExtensions()) { boolean found = false; for(final Extension current : new ArrayList<>(target.getExtensions())) { if ( current.getName().equals(ext.getName()) ) { found = true; target.getExtensions().add(ext); for(final Extension ext : target.getExtensions()) { for(final PostProcessHandler ppe : context.getPostProcessExtensions()) { ppe.postProcess(new HandlerContextImpl(context, ppe), target, ext);
@Override public final void execute(AnalyserTaskContext ctx) throws Exception { Feature feature = ctx.getFeature(); // extract and check the api-regions Extensions extensions = feature.getExtensions(); Extension apiRegionsExtension = extensions.getByName(API_REGIONS_KEY); if (apiRegionsExtension == null) { // no need to be analyzed return; } String jsonRepresentation = apiRegionsExtension.getJSON(); if (jsonRepresentation == null || jsonRepresentation.isEmpty()) { // no need to be analyzed return; } // read the api-regions and create a Sieve data structure for checks ApiRegions apiRegions; try { apiRegions = ApiRegions.fromJson(jsonRepresentation); } catch (JsonParsingException e) { ctx.reportError("API Regions '" + jsonRepresentation + "' does not represent a valid JSON 'api-regions': " + e.getMessage()); return; } execute(apiRegions, ctx); }
private static List<org.apache.sling.feature.Feature> buildFeatures(Model model, String bareFileName, Map<String, Object> options) { final List<org.apache.sling.feature.Feature> features = new ArrayList<>(); String groupId = getOption(options, "groupId", "generated"); String version = getOption(options, "version", "1.0.0"); for(final Feature feature : model.getFeatures() ) { final String idString; String name = feature.getName(); if ( name != null ) { name = name.replaceAll("[:]", ""); if (!name.equals(bareFileName)) { name = bareFileName + "_" + name; } if ( feature.getVersion() != null ) { idString = groupId + "/" + name + "/" + feature.getVersion(); } else { idString = groupId + "/" + name + "/" + version; } } else { idString = groupId + "/feature/" + version; } final org.apache.sling.feature.Feature f = new org.apache.sling.feature.Feature(ArtifactId.parse(idString)); features.add(f); buildFromFeature(feature, f.getVariables(), f.getBundles(), f.getConfigurations(), f.getExtensions(), f.getFrameworkProperties()); if (!f.getId().getArtifactId().equals(feature.getName())) { f.getVariables().put(FeatureToProvisioning.PROVISIONING_MODEL_NAME_VARIABLE, feature.getName()); } } return features; }
for (final Extension ext : feature.getExtensions()) { if ( ext.getName().equals(name) ) { feature.getExtensions().remove(ext); break; for (final Extension ext : feature.getExtensions()) { if ( ext.getName().equals(entry.getKey()) ) { for(final ArtifactId toRemove : entry.getValue() ) {
result.getCapabilities().clear(); result.setPrototype(null); result.getExtensions().clear(); a.getMetadata().remove(TRACKING_KEY); for (Extension e : result.getExtensions()) { if (ExtensionType.ARTIFACTS == e.getType()) { for (Artifact a : e.getArtifacts()) {
list.getArtifacts().add(new Artifact(id)); target.getExtensions().add(list);
for(final Extension e : this.getExtensions()) { final Extension c = new Extension(e.getType(), e.getName(), e.isRequired()); switch ( c.getType() ) { break; result.getExtensions().add(c);