use of com.google.gerrit.extensions.restapi.IdString in project gerrit by GerritCodeReview.
the class Comments method parse.
@Override
public CommentResource parse(RevisionResource rev, IdString id) throws ResourceNotFoundException, OrmException {
String uuid = id.get();
ChangeNotes notes = rev.getNotes();
for (Comment c : commentsUtil.publishedByPatchSet(dbProvider.get(), notes, rev.getPatchSet().getId())) {
if (uuid.equals(c.key.uuid)) {
return new CommentResource(rev, c);
}
}
throw new ResourceNotFoundException(id);
}
use of com.google.gerrit.extensions.restapi.IdString in project gerrit by GerritCodeReview.
the class CachesCollection method parse.
@Override
public CacheResource parse(ConfigResource parent, IdString id) throws AuthException, ResourceNotFoundException, PermissionBackendException {
permissionBackend.user(self).check(GlobalPermission.VIEW_CACHES);
String cacheName = id.get();
String pluginName = "gerrit";
int i = cacheName.lastIndexOf('-');
if (i != -1) {
pluginName = cacheName.substring(0, i);
cacheName = cacheName.length() > i + 1 ? cacheName.substring(i + 1) : "";
}
Provider<Cache<?, ?>> cacheProvider = cacheMap.byPlugin(pluginName).get(cacheName);
if (cacheProvider == null) {
throw new ResourceNotFoundException(id);
}
return new CacheResource(pluginName, cacheName, cacheProvider);
}
use of com.google.gerrit.extensions.restapi.IdString in project gerrit by GerritCodeReview.
the class BranchesCollection method parse.
@Override
public BranchResource parse(ProjectResource parent, IdString id) throws ResourceNotFoundException, IOException, BadRequestException {
String branchName = id.get();
if (!branchName.equals(Constants.HEAD)) {
branchName = RefNames.fullName(branchName);
}
List<BranchInfo> branches = list.get().apply(parent);
for (BranchInfo b : branches) {
if (branchName.equals(b.ref)) {
return new BranchResource(parent.getControl(), b);
}
}
throw new ResourceNotFoundException();
}
use of com.google.gerrit.extensions.restapi.IdString in project gerrit by GerritCodeReview.
the class ListTags method get.
public TagInfo get(ProjectResource resource, IdString id) throws ResourceNotFoundException, IOException {
try (Repository repo = getRepository(resource.getNameKey());
RevWalk rw = new RevWalk(repo)) {
String tagName = id.get();
if (!tagName.startsWith(Constants.R_TAGS)) {
tagName = Constants.R_TAGS + tagName;
}
Ref ref = repo.getRefDatabase().exactRef(tagName);
ProjectControl control = resource.getControl();
if (ref != null && !visibleTags(control, repo, ImmutableMap.of(ref.getName(), ref)).isEmpty()) {
return createTagInfo(permissionBackend.user(control.getUser()).project(resource.getNameKey()).ref(ref.getName()), ref, rw);
}
}
throw new ResourceNotFoundException(id);
}
Aggregations