use of io.apicurio.datamodels.core.models.common.ISecurityRequirementParent in project apicurio-data-models by Apicurio.
the class DeleteSecurityRequirementCommand method undo.
/**
* @see io.apicurio.datamodels.cmd.ICommand#undo(io.apicurio.datamodels.core.models.Document)
*/
@Override
public void undo(Document document) {
LoggerCompat.info("[DeleteSecurityRequirementCommand] Reverting.");
if (this.isNullOrUndefined(this._oldRequirement)) {
return;
}
ISecurityRequirementParent parent = (ISecurityRequirementParent) this._parentPath.resolve(document);
if (this.isNullOrUndefined(parent)) {
return;
}
SecurityRequirement restoredRequirement = parent.createSecurityRequirement();
Library.readNode(this._oldRequirement, restoredRequirement);
parent.addSecurityRequirement(restoredRequirement);
}
use of io.apicurio.datamodels.core.models.common.ISecurityRequirementParent in project apicurio-data-models by Apicurio.
the class DeleteAllSecurityRequirementsCommand method undo.
/**
* @see io.apicurio.datamodels.cmd.ICommand#undo(io.apicurio.datamodels.core.models.Document)
*/
@Override
public void undo(Document document) {
LoggerCompat.info("[DeleteAllSecurityRequirementsCommand] Reverting.");
if (ModelUtils.isDefined(this._oldSecurityRequirements) && this._oldSecurityRequirements.size() == 0) {
return;
}
ISecurityRequirementParent parent = (ISecurityRequirementParent) this._parentPath.resolve(document);
if (this.isNullOrUndefined(parent)) {
return;
}
List<SecurityRequirement> requirements = parent.getSecurityRequirements();
if (this.isNullOrUndefined(requirements)) {
requirements = new ArrayList<>();
NodeCompat.setProperty(parent, Constants.PROP_SECURITY, requirements);
}
for (Object oldSecurityRequirement : this._oldSecurityRequirements) {
SecurityRequirement requirement = parent.createSecurityRequirement();
Library.readNode(oldSecurityRequirement, requirement);
requirements.add(requirement);
}
}
use of io.apicurio.datamodels.core.models.common.ISecurityRequirementParent in project apicurio-data-models by Apicurio.
the class SecurityRequirementUniquenessValidationRule method visitSecurityRequirement.
/**
* @param node
* @see io.apicurio.datamodels.combined.visitors.CombinedAllNodeVisitor#visitSecurityRequirement(io.apicurio.datamodels.core.models.common.SecurityRequirement)
*/
public void visitSecurityRequirement(SecurityRequirement node) {
ISecurityRequirementParent parent = (ISecurityRequirementParent) node.parent();
List<SecurityRequirement> securityRequirements = parent.getSecurityRequirements();
if (securityRequirements.size() <= 1) {
return;
}
if (checkForDuplicates(node, securityRequirements)) {
this.report(node, Constants.PROP_SECURITY, map("securityReq", node.getSecurityRequirementNames().toString()));
}
}
use of io.apicurio.datamodels.core.models.common.ISecurityRequirementParent in project apicurio-data-models by Apicurio.
the class ReplaceSecurityRequirementCommand method undo.
/**
* @see io.apicurio.datamodels.cmd.ICommand#undo(io.apicurio.datamodels.core.models.Document)
*/
@Override
public void undo(Document document) {
LoggerCompat.info("[ReplaceSecurityRequirementCommand] Reverting.");
if (!this._replaced) {
return;
}
ISecurityRequirementParent parent = (ISecurityRequirementParent) this._parentPath.resolve(document);
if (this.isNullOrUndefined(parent)) {
return;
}
SecurityRequirement replacementRequirement = parent.createSecurityRequirement();
Library.readNode(this._newRequirement, replacementRequirement);
int idx = this.indexOfRequirement(parent.getSecurityRequirements(), replacementRequirement);
if (idx == -1) {
return;
}
SecurityRequirement originalRequirement = parent.createSecurityRequirement();
Library.readNode(this._oldRequirement, originalRequirement);
parent.getSecurityRequirements().set(idx, originalRequirement);
}
use of io.apicurio.datamodels.core.models.common.ISecurityRequirementParent in project apicurio-data-models by Apicurio.
the class Oas20to30TransformationVisitor method visitSecurityRequirement.
/**
* @see io.apicurio.datamodels.core.visitors.IVisitor#visitSecurityRequirement(io.apicurio.datamodels.core.models.common.SecurityRequirement)
*/
@Override
public void visitSecurityRequirement(SecurityRequirement node) {
Oas20SecurityRequirement req = (Oas20SecurityRequirement) node;
ISecurityRequirementParent parent30 = (ISecurityRequirementParent) this.lookup(req.parent());
Oas30SecurityRequirement securityRequirement30 = (Oas30SecurityRequirement) parent30.createSecurityRequirement();
parent30.addSecurityRequirement(securityRequirement30);
req.getSecurityRequirementNames().forEach(name -> {
securityRequirement30.addSecurityRequirementItem(name, req.getScopes(name));
});
this.mapNode(req, securityRequirement30);
}
Aggregations