in src/main/java/org/apache/sling/feature/Artifact.java [83:111]
public Artifact(final JsonValue json) {
if ( json == null ) {
throw new IllegalArgumentException("json must not be null.");
}
if ( json.getValueType() == ValueType.STRING ) {
this.id = ArtifactId.parse(((JsonString)json).getString());
} else if ( json.getValueType() == ValueType.OBJECT) {
String id = json.asJsonObject().getString(KEY_ID, null);
if ( id == null ) {
throw new IllegalArgumentException("JSON for artifact is missing id property");
}
this.id = ArtifactId.parse(id);
for(final Map.Entry<String, JsonValue> metadataEntry : json.asJsonObject().entrySet()) {
final String key = metadataEntry.getKey();
if ( KEY_ID.equals(key) ) {
continue;
}
final JsonValue value = metadataEntry.getValue();
if ( value.getValueType() == ValueType.STRING || value.getValueType() == ValueType.NUMBER || value.getValueType() == ValueType.FALSE || value.getValueType() == ValueType.TRUE ) {
this.getMetadata().put(key, org.apache.felix.cm.json.io.Configurations.convertToObject(value).toString());
} else {
throw new IllegalArgumentException("Key ".concat(key).concat(" is not one of the allowed types string, number or boolean : ").concat(value.getValueType().name()));
}
}
} else {
throw new IllegalArgumentException("JSON for artifact must be of type object or string");
}
}