Search in sources :

Example 1 with LabelResource

use of com.google.gerrit.server.project.LabelResource in project gerrit by GerritCodeReview.

the class LabelsCollection method parse.

@Override
public LabelResource parse(ProjectResource parent, IdString id) throws AuthException, ResourceNotFoundException, PermissionBackendException {
    if (!user.get().isIdentifiedUser()) {
        throw new AuthException("Authentication required");
    }
    permissionBackend.currentUser().project(parent.getNameKey()).check(ProjectPermission.READ_CONFIG);
    LabelType labelType = parent.getProjectState().getConfig().getLabelSections().get(id.get());
    if (labelType == null) {
        throw new ResourceNotFoundException(id);
    }
    return new LabelResource(parent, labelType);
}
Also used : LabelResource(com.google.gerrit.server.project.LabelResource) LabelType(com.google.gerrit.entities.LabelType) AuthException(com.google.gerrit.extensions.restapi.AuthException) ResourceNotFoundException(com.google.gerrit.extensions.restapi.ResourceNotFoundException)

Aggregations

LabelType (com.google.gerrit.entities.LabelType)1 AuthException (com.google.gerrit.extensions.restapi.AuthException)1 ResourceNotFoundException (com.google.gerrit.extensions.restapi.ResourceNotFoundException)1 LabelResource (com.google.gerrit.server.project.LabelResource)1