use of com.artipie.front.api.NotFoundException in project front by artipie.
the class RepoSettings method key.
/**
* Find repository settings key by repository name and username, throws exception
* if settings file is not found.
* @param name Repository name
* @param uid User id (=name)
* @return Repository settings
* @throws NotFoundException If such repository does not exist
*/
public Key key(final String name, final String uid) {
final Pair<Key, Key> pair = this.keys(name, uid);
Key res = pair.getLeft();
if (!this.repos.exists(res)) {
res = pair.getRight();
if (!this.repos.exists(res)) {
throw new NotFoundException(String.format("Repository %s not found", name));
}
}
return res;
}
use of com.artipie.front.api.NotFoundException in project front by artipie.
the class YamlStorages method remove.
@Override
public void remove(final String alias) {
final Optional<YamlMapping> storages = this.storages();
if (storages.isPresent() && storages.get().value(alias) != null) {
YamlMappingBuilder builder = Yaml.createYamlMappingBuilder();
for (final YamlNode node : storages.get().keys()) {
final String name = node.asScalar().value();
if (!alias.equals(name)) {
builder = builder.add(name, storages.get().yamlMapping(name));
}
}
this.blsto.save(this.key().get(), Yaml.createYamlMappingBuilder().add(YamlStorages.STORAGES_NODE, builder.build()).build().toString().getBytes(StandardCharsets.UTF_8));
return;
}
throw new NotFoundException(String.format("Storage alias %s does not exist", alias));
}
use of com.artipie.front.api.NotFoundException in project front by artipie.
the class YamlUsers method remove.
@Override
public void remove(final String uid) {
if (this.users().map(yaml -> yaml.yamlMapping(uid) != null).orElse(false)) {
YamlMappingBuilder builder = Yaml.createYamlMappingBuilder();
final YamlMapping users = this.users().get();
for (final YamlNode node : users.keys()) {
final String val = node.asScalar().value();
if (!uid.equals(val)) {
builder = builder.add(val, users.yamlMapping(val));
}
}
this.blsto.save(this.key, Yaml.createYamlMappingBuilder().add(ArtipieYaml.NODE_CREDENTIALS, builder.build()).build().toString().getBytes(StandardCharsets.UTF_8));
return;
}
throw new NotFoundException(String.format("User %s does not exist", uid));
}
Aggregations