use of com.artipie.asto.Key in project artipie by artipie.
the class ConfigFile method delete.
/**
* Deletes value from the storage.
* @param storage Storage where the file with different extensions is checked for existence
* @return Result of completion.
*/
public CompletionStage<Void> delete(final Storage storage) {
final CompletionStage<Void> res;
if (this.isYamlOrYml() || this.extension().isEmpty()) {
final String name = this.name();
final Key yaml = Extension.YAML.key(name);
res = storage.exists(yaml).thenCompose(exist -> {
final CompletionStage<Void> result;
if (exist) {
result = storage.delete(yaml);
} else {
result = storage.delete(Extension.YML.key(name));
}
return result;
});
} else {
res = CompletableFuture.allOf();
}
return res;
}
use of com.artipie.asto.Key in project artipie by artipie.
the class ConfigFile method existsIn.
/**
* Does config file exist in the specified storage?
* @param storage Storage where the file with different extensions is checked for existence
* @return True if a file with either of the two extensions exists, false otherwise.
*/
public CompletionStage<Boolean> existsIn(final Storage storage) {
final CompletionStage<Boolean> res;
if (this.isYamlOrYml() || this.extension().isEmpty()) {
final String name = this.name();
final Key yaml = Extension.YAML.key(name);
res = storage.exists(yaml).thenCompose(exist -> {
final CompletionStage<Boolean> result;
if (exist) {
result = CompletableFuture.completedFuture(true);
} else {
final Key yml = Extension.YML.key(name);
result = storage.exists(yml);
}
return result;
});
} else {
res = CompletableFuture.completedFuture(false);
}
return res;
}
Aggregations