use of io.apicurio.datamodels.asyncapi.v2.models.Aai20NodeFactory in project apicurio-data-models by Apicurio.
the class DeleteSchemaDefinitionCommand_Aai20 method doRestoreSchemaDefinition.
/**
* @see DeleteSchemaDefinitionCommand#doRestoreSchemaDefinition(Document, Object)
*/
@Override
protected void doRestoreSchemaDefinition(Document document, Object oldDefinition) {
Aai20Document aai20Document = (Aai20Document) document;
if (ModelUtils.isDefined(aai20Document.components)) {
AaiSchema schemaDef = new Aai20NodeFactory().createSchemaDefinition(aai20Document.components, this._definitionName);
Library.readNode(oldDefinition, schemaDef);
aai20Document.components.addSchemaDefinition(this._definitionName, schemaDef);
}
}
use of io.apicurio.datamodels.asyncapi.v2.models.Aai20NodeFactory in project apicurio-data-models by Apicurio.
the class NewMessageDefinitionCommand method execute.
@Override
public void execute(Document document) {
LoggerCompat.info("[NewMessageDefinitionCommand] Executing.");
Aai20Document doc20 = (Aai20Document) document;
if (this.isNullOrUndefined(doc20.components)) {
doc20.components = doc20.createComponents();
this._nullComponents = true;
}
this._nullComponents = false;
Aai20Components components = (Aai20Components) doc20.components;
if (this.isNullOrUndefined(components.getMessageTraitDefinition(_newName))) {
Aai20NodeFactory factory = new Aai20NodeFactory();
AaiMessage msgDef = factory.createMessage(components, _newName);
if (!this.isNullOrUndefined(_newDescription != null)) {
msgDef.description = _newDescription;
}
components.addMessage(_newName, msgDef);
this._defExisted = false;
} else {
this._defExisted = true;
}
}
use of io.apicurio.datamodels.asyncapi.v2.models.Aai20NodeFactory in project apicurio-data-models by Apicurio.
the class NewOperationCommand_Aai20 method execute.
/**
* @see io.apicurio.datamodels.cmd.ICommand#execute(Document)
*/
@Override
public void execute(Document document) {
LoggerCompat.info("[NewOperationCommand_Aai20] Executing.");
AaiDocument adoc = (AaiDocument) document;
this._created = false;
if (this.isNullOrUndefined(adoc.channels)) {
return;
}
AaiChannelItem channel = adoc.channels.get(this._channel);
if (this.isNullOrUndefined(channel)) {
return;
}
if (!"subscribe".equals(this._opType) && !"publish".equals(this._opType)) {
return;
}
Aai20NodeFactory nodeFactory = new Aai20NodeFactory();
AaiOperation operation = nodeFactory.createOperation(channel, this._opType);
operation.message = nodeFactory.createMessage(operation, null);
operation.message.payload = JsonCompat.objectNode();
switch(this._opType) {
case "subscribe":
channel.subscribe = operation;
break;
case "publish":
channel.publish = operation;
break;
}
this._created = true;
}
use of io.apicurio.datamodels.asyncapi.v2.models.Aai20NodeFactory 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.v2.models.Aai20NodeFactory in project apicurio-data-models by Apicurio.
the class NewSecuritySchemeCommand_Aai20 method execute.
/**
* @see io.apicurio.datamodels.cmd.ICommand#execute(Document)
*/
@Override
public void execute(Document document) {
LoggerCompat.info("[NewSecuritySchemeCommand_Aai20] Executing.");
Aai20Document aai20Document = (Aai20Document) document;
this._nullComponents = false;
if (this.isNullOrUndefined(aai20Document.components)) {
aai20Document.components = aai20Document.createComponents();
this._nullComponents = true;
}
if (this.isNullOrUndefined(aai20Document.components.getSecurityScheme(this._schemeName))) {
AaiSecurityScheme scheme = new Aai20NodeFactory().createSecurityScheme(aai20Document.components, this._schemeName);
Library.readNode(this._scheme, scheme);
aai20Document.components.addSecurityScheme(this._schemeName, scheme);
this._schemeExisted = false;
} else {
this._schemeExisted = true;
}
}
Aggregations