Search in sources :

Example 1 with AaiServer

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);
}
Also used : Aai20Document(io.apicurio.datamodels.asyncapi.v2.models.Aai20Document) AaiServer(io.apicurio.datamodels.asyncapi.models.AaiServer)

Example 2 with AaiServer

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);
}
Also used : Aai20Document(io.apicurio.datamodels.asyncapi.v2.models.Aai20Document) AaiServer(io.apicurio.datamodels.asyncapi.models.AaiServer)

Example 3 with AaiServer

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);
}
Also used : Aai20Document(io.apicurio.datamodels.asyncapi.v2.models.Aai20Document) AaiServer(io.apicurio.datamodels.asyncapi.models.AaiServer)

Example 4 with AaiServer

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<>());
}
Also used : Aai20Document(io.apicurio.datamodels.asyncapi.v2.models.Aai20Document) AaiServer(io.apicurio.datamodels.asyncapi.models.AaiServer)

Example 5 with AaiServer

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);
}
Also used : AaiServer(io.apicurio.datamodels.asyncapi.models.AaiServer)

Aggregations

AaiServer (io.apicurio.datamodels.asyncapi.models.AaiServer)12 Aai20Document (io.apicurio.datamodels.asyncapi.v2.models.Aai20Document)8 AaiChannelItem (io.apicurio.datamodels.asyncapi.models.AaiChannelItem)1 AaiComponents (io.apicurio.datamodels.asyncapi.models.AaiComponents)1 AaiDocument (io.apicurio.datamodels.asyncapi.models.AaiDocument)1 AaiSecurityRequirement (io.apicurio.datamodels.asyncapi.models.AaiSecurityRequirement)1 AaiServerBindings (io.apicurio.datamodels.asyncapi.models.AaiServerBindings)1 Aai20Server (io.apicurio.datamodels.asyncapi.v2.models.Aai20Server)1 Server (io.apicurio.datamodels.core.models.common.Server)1