use of io.apicurio.datamodels.asyncapi.models.AaiHeaderItem in project apicurio-data-models by Apicurio.
the class ChangeHeadersRefCommand_Aai20 method execute.
@Override
public void execute(Document document) {
LoggerCompat.info("[ChangeHeadersRefCommand_Aai20] Executing.");
AaiOperation operation = (AaiOperation) this._operationPath.resolve(document);
this._changed = false;
if (this.isNullOrUndefined(operation) || this.isNullOrUndefined(operation.message) || !isValidRef(this._headersRef)) {
return;
}
AaiHeaderItem headerItem = operation.message.headers;
if (headerItem == null) {
Aai20NodeFactory nodeFactory = new Aai20NodeFactory();
headerItem = nodeFactory.createHeaderItem(operation.message);
operation.message.headers = headerItem;
}
if (headerItem.$ref != null) {
this._oldHeadersRef = headerItem.$ref;
}
headerItem.$ref = this._headersRef;
this._changed = true;
}
use of io.apicurio.datamodels.asyncapi.models.AaiHeaderItem in project apicurio-data-models by Apicurio.
the class AaiDataModelReader method readMessageBase.
public void readMessageBase(Object json, AaiMessageBase node) {
// headers
Object jsonHeaders = JsonCompat.consumeProperty(json, Constants.PROP_HEADERS);
if (jsonHeaders != null) {
AaiHeaderItem headerModel = nodeFactory.createHeaderItem(node);
this.readHeaderItem(jsonHeaders, headerModel);
node.headers = headerModel;
}
// correlationId
Object jsonCI = JsonCompat.consumeProperty(json, Constants.PROP_CORRELATION_ID);
if (jsonCI != null) {
AaiCorrelationId value = nodeFactory.createCorrelationId(node, null);
this.readCorrelationId(jsonCI, value);
node.correlationId = value;
}
// String properties
node.schemaFormat = JsonCompat.consumePropertyString(json, Constants.PROP_SCHEMA_FORMAT);
node.contentType = JsonCompat.consumePropertyString(json, Constants.PROP_CONTENT_TYPE);
node.name = JsonCompat.consumePropertyString(json, Constants.PROP_NAME);
node.title = JsonCompat.consumePropertyString(json, Constants.PROP_TITLE);
node.summary = JsonCompat.consumePropertyString(json, Constants.PROP_SUMMARY);
node.description = JsonCompat.consumePropertyString(json, Constants.PROP_DESCRIPTION);
node.$ref = JsonCompat.consumePropertyString(json, Constants.PROP_$REF);
// tags
List<Object> jsonTags = JsonCompat.consumePropertyArray(json, Constants.PROP_TAGS);
if (jsonTags != null) {
jsonTags.forEach(j -> {
AaiTag tag = nodeFactory.createTag(node);
this.readTag(j, tag);
node.addTag(tag);
});
}
// external docs
Object jsonED = JsonCompat.consumeProperty(json, Constants.PROP_EXTERNAL_DOCS);
if (jsonED != null) {
AaiExternalDocumentation value = nodeFactory.createExternalDocumentation(node);
this.readExternalDocumentation(jsonED, value);
node.externalDocs = value;
}
// bindings
Object bindings = JsonCompat.consumeProperty(json, Constants.PROP_BINDINGS);
if (bindings != null) {
AaiMessageBindings bindingsModel = nodeFactory.createMessageBindings(node);
this.readMessageBindings(bindings, bindingsModel);
node.bindings = bindingsModel;
}
// examples
List<Object> examples = JsonCompat.consumePropertyArray(json, Constants.PROP_EXAMPLES);
if (examples != null) {
List<Map<String, Object>> examplesList = new ArrayList<>();
this.readMessageExamples(examples, examplesList);
node.examples = examplesList;
}
this.readExtensions(json, node);
this.readExtraProperties(json, node);
}
use of io.apicurio.datamodels.asyncapi.models.AaiHeaderItem in project apicurio-data-models by Apicurio.
the class ChangeHeadersRefCommand_Aai20 method undo.
@Override
public void undo(Document document) {
LoggerCompat.info("[ChangeHeadersRefCommand_Aai20] Reverting.");
AaiOperation operation = (AaiOperation) this._operationPath.resolve(document);
if (!this._changed || this.isNullOrUndefined(operation) || this.isNullOrUndefined(operation.message)) {
return;
}
AaiHeaderItem headerItem = operation.message.headers;
if (this._oldHeadersRef != null) {
headerItem.$ref = this._oldHeadersRef;
} else {
headerItem.$ref = null;
}
}
Aggregations