use of io.apicurio.datamodels.openapi.v3.models.IOas30MediaTypeParent in project apicurio-data-models by Apicurio.
the class NewMediaTypeCommand method undo.
/**
* @see io.apicurio.datamodels.cmd.ICommand#undo(io.apicurio.datamodels.core.models.Document)
*/
@Override
public void undo(Document document) {
LoggerCompat.info("[NewMediaTypeCommand] Reverting.");
if (!this._created) {
LoggerCompat.info("[NewMediaTypeCommand] media type already existed, nothing done so no rollback necessary.");
return;
}
IOas30MediaTypeParent node = (IOas30MediaTypeParent) this._nodePath.resolve(document);
if (this.isNullOrUndefined(node)) {
return;
}
node.removeMediaType(this._newMediaType);
}
use of io.apicurio.datamodels.openapi.v3.models.IOas30MediaTypeParent in project apicurio-data-models by Apicurio.
the class DeleteMediaTypeCommand method undo.
/**
* @see io.apicurio.datamodels.cmd.ICommand#undo(io.apicurio.datamodels.core.models.Document)
*/
@Override
public void undo(Document document) {
LoggerCompat.info("[DeleteMediaTypeCommand] Reverting.");
if (this.isNullOrUndefined(this._oldMediaType)) {
return;
}
IOas30MediaTypeParent parent = (IOas30MediaTypeParent) this._parentPath.resolve(document);
if (this.isNullOrUndefined(parent)) {
return;
}
Oas30MediaType mediaType = parent.createMediaType(this._mediaTypeName);
Library.readNode(this._oldMediaType, mediaType);
parent.addMediaType(this._mediaTypeName, mediaType);
}
use of io.apicurio.datamodels.openapi.v3.models.IOas30MediaTypeParent in project apicurio-data-models by Apicurio.
the class NewMediaTypeCommand method execute.
/**
* @see io.apicurio.datamodels.cmd.ICommand#execute(io.apicurio.datamodels.core.models.Document)
*/
@Override
public void execute(Document document) {
LoggerCompat.info("[NewMediaTypeCommand] Executing.");
this._created = false;
IOas30MediaTypeParent node = (IOas30MediaTypeParent) this._nodePath.resolve(document);
if (this.isNullOrUndefined(node)) {
return;
}
Oas30MediaType mediaType = node.getMediaType(this._newMediaType);
if (ModelUtils.isDefined(mediaType)) {
return;
}
node.addMediaType(this._newMediaType, node.createMediaType(this._newMediaType));
this._created = true;
}
use of io.apicurio.datamodels.openapi.v3.models.IOas30MediaTypeParent in project apicurio-data-models by Apicurio.
the class DeleteMediaTypeCommand method execute.
/**
* @see io.apicurio.datamodels.cmd.ICommand#execute(io.apicurio.datamodels.core.models.Document)
*/
@Override
public void execute(Document document) {
LoggerCompat.info("[DeleteMediaTypeCommand] Executing.");
this._oldMediaType = null;
Oas30MediaType mediaType = (Oas30MediaType) this._mediaTypePath.resolve(document);
if (this.isNullOrUndefined(mediaType)) {
return;
}
IOas30MediaTypeParent parent = (IOas30MediaTypeParent) mediaType.parent();
parent.removeMediaType(this._mediaTypeName);
this._oldMediaType = Library.writeNode(mediaType);
}
Aggregations