private Feature readFeature()

in src/main/java/org/apache/sling/feature/io/json/FeatureJSONReader.java [674:732]


    private Feature readFeature(final Reader reader)
    throws IOException {
        final JsonObject json = Json.createReader(org.apache.felix.cm.json.io.Configurations.jsonCommentAwareReader(reader)).readObject();

        checkModelVersion(json);

        final ArtifactId featureId = this.getFeatureId(json);
        this.feature = new Feature(featureId);
        this.feature.setLocation(this.location);

        // final flag
        if (json.containsKey(JSONConstants.FEATURE_FINAL)) {
            this.feature.setFinal(checkTypeBoolean(JSONConstants.FEATURE_FINAL, json.get(JSONConstants.FEATURE_FINAL)));
        }

        // complete flag
        if (json.containsKey(JSONConstants.FEATURE_COMPLETE)) {
            this.feature.setComplete(checkTypeBoolean(JSONConstants.FEATURE_COMPLETE, json.get(JSONConstants.FEATURE_COMPLETE)));
        }

        // title, description, vendor and license, docURL, scmInfo
        this.feature.setTitle(getProperty(json, JSONConstants.FEATURE_TITLE));
        this.feature.setDescription(getProperty(json, JSONConstants.FEATURE_DESCRIPTION));
        this.feature.setVendor(getProperty(json, JSONConstants.FEATURE_VENDOR));
        this.feature.setLicense(getProperty(json, JSONConstants.FEATURE_LICENSE));
        this.feature.setDocURL(getProperty(json, JSONConstants.FEATURE_DOC_URL));
        this.feature.setSCMInfo(getProperty(json, JSONConstants.FEATURE_SCM_INFO));

        // categories
        if ( json.containsKey(JSONConstants.FEATURE_CATEGORIES) ) {
            for(final JsonValue val : checkTypeArray(JSONConstants.FEATURE_CATEGORIES, json.get(JSONConstants.FEATURE_CATEGORIES))) {
                this.feature.getCategories().add(checkTypeString("Categories", val));
            }
        }

        this.readVariables(json, feature.getVariables());
        this.readBundles(json, feature.getBundles(), feature.getConfigurations());
        this.readFrameworkProperties(json, feature.getFrameworkProperties());
        this.readConfigurations(json, feature.getConfigurations());

        this.readCapabilities(json, feature.getCapabilities());
        this.readRequirements(json, feature.getRequirements());
        this.feature.setPrototype(this.readPrototype(json));

        this.readExtensions(json,
                JSONConstants.FEATURE_KNOWN_PROPERTIES,
                this.feature.getExtensions(), this.feature.getConfigurations());

        // check for internal metadata extension
        final Extension internalData = this.feature.getExtensions().getByName(Extension.EXTENSION_NAME_INTERNAL_DATA);
        if ( internalData != null ) {
            this.feature.getExtensions().remove(internalData);
            if ( internalData.getType() != ExtensionType.JSON ) {
                throw new IOException("Extension " + internalData.getName() + " must be of type JSON");
            }
            this.setInternalData(internalData);
        }
        return this.feature;
    }