use of io.apicurio.datamodels.asyncapi.models.AaiServer in project apicurio-data-models by Apicurio.
the class DeleteServerCommand_Aai20 method undo.
/**
* @see io.apicurio.datamodels.cmd.ICommand#undo(Document)
*/
@Override
public void undo(Document document) {
LoggerCompat.info("[DeleteServerCommand_Aai20] Reverting.");
if (this.isNullOrUndefined(this._oldServer)) {
return;
}
Aai20Document parent = (Aai20Document) document;
if (this.isNullOrUndefined(parent)) {
return;
}
AaiServer server = parent.createServer(_serverName);
Library.readNode(this._oldServer, server);
Map<String, AaiServer> servers = parent.servers;
if (this.isNullOrUndefined(servers)) {
servers = new LinkedHashMap<>();
NodeCompat.setProperty(parent, Constants.PROP_SERVERS, servers);
}
servers.put(_serverName, server);
}
use of io.apicurio.datamodels.asyncapi.models.AaiServer in project apicurio-data-models by Apicurio.
the class ChangeServerCommand_Aai20 method execute.
/**
* @see io.apicurio.datamodels.cmd.ICommand#execute(Document)
*/
@Override
public void execute(Document document) {
LoggerCompat.info("[ChangeServerCommand_Aai20] Executing.");
this._oldServer = null;
Aai20Document parent = (Aai20Document) document;
if (this.isNullOrUndefined(parent.servers)) {
return;
}
AaiServer server = parent.servers.get(_serverName);
if (this.isNullOrUndefined(server)) {
return;
}
// Back up the old server info (for undo)
this._oldServer = Library.writeNode(server);
// Replace with new server info
this.replaceServerWith(server, this._serverObj);
}
use of io.apicurio.datamodels.asyncapi.models.AaiServer in project apicurio-data-models by Apicurio.
the class ChangeServerCommand_Aai20 method undo.
/**
* @see io.apicurio.datamodels.cmd.ICommand#undo(Document)
*/
@Override
public void undo(Document document) {
LoggerCompat.info("[ChangeServerCommand_Aai20] Reverting.");
if (this.isNullOrUndefined(this._oldServer)) {
return;
}
Aai20Document parent = (Aai20Document) document;
if (this.isNullOrUndefined(parent.servers)) {
return;
}
AaiServer server = parent.servers.get(_serverName);
if (this.isNullOrUndefined(server)) {
return;
}
this.replaceServerWith(server, this._oldServer);
}
use of io.apicurio.datamodels.asyncapi.models.AaiServer in project apicurio-data-models by Apicurio.
the class DeleteAllServersCommand_Aai20 method execute.
/**
* @see io.apicurio.datamodels.cmd.ICommand#execute(Document)
*/
@Override
public void execute(Document document) {
LoggerCompat.info("[DeleteAllServersCommand_Aai20] Executing.");
this._oldServers = new LinkedHashMap<>();
Aai20Document parent = (Aai20Document) document;
if (this.isNullOrUndefined(parent.servers)) {
return;
}
// Save the old servers (if any)
Map<String, AaiServer> servers = parent.servers;
if (!this.isNullOrUndefined(servers)) {
servers.keySet().forEach(serverName -> {
this._oldServers.put(serverName, Library.writeNode(servers.get(serverName)));
});
}
NodeCompat.setProperty(parent, Constants.PROP_SERVERS, new LinkedHashMap<>());
}
use of io.apicurio.datamodels.asyncapi.models.AaiServer in project apicurio-data-models by Apicurio.
the class AaiDataModelWriter method writeServer.
protected void writeServer(Object json, Server node) {
JsonCompat.setPropertyString(json, Constants.PROP_URL, node.url);
JsonCompat.setPropertyString(json, Constants.PROP_DESCRIPTION, node.description);
JsonCompat.setPropertyNull(json, Constants.PROP_VARIABLES);
AaiServer server = (AaiServer) node;
JsonCompat.setPropertyString(json, Constants.PROP_PROTOCOL, server.protocol);
JsonCompat.setPropertyString(json, Constants.PROP_PROTOCOL_VERSION, server.protocolVersion);
JsonCompat.setPropertyNull(json, Constants.PROP_SECURITY);
JsonCompat.setPropertyNull(json, Constants.PROP_BINDINGS);
}
Aggregations