Search in sources :

Example 1 with GlobalPermission

use of com.google.gerrit.server.permissions.GlobalPermission in project gerrit by GerritCodeReview.

the class Capabilities method parse.

private GlobalOrPluginPermission parse(IdString id) throws ResourceNotFoundException {
    String name = id.get();
    Optional<GlobalPermission> perm = globalPermission(name);
    if (perm.isPresent()) {
        return perm.get();
    }
    int dash = name.lastIndexOf('-');
    if (dash < 0) {
        throw new ResourceNotFoundException(id);
    }
    String pluginName = name.substring(0, dash);
    String capability = name.substring(dash + 1);
    if (pluginName.isEmpty() || capability.isEmpty()) {
        throw new ResourceNotFoundException(id);
    }
    return new PluginPermission(pluginName, capability);
}
Also used : GlobalOrPluginPermission(com.google.gerrit.extensions.api.access.GlobalOrPluginPermission) PluginPermission(com.google.gerrit.extensions.api.access.PluginPermission) GlobalPermission(com.google.gerrit.server.permissions.GlobalPermission) IdString(com.google.gerrit.extensions.restapi.IdString) ResourceNotFoundException(com.google.gerrit.extensions.restapi.ResourceNotFoundException)

Aggregations

GlobalOrPluginPermission (com.google.gerrit.extensions.api.access.GlobalOrPluginPermission)1 PluginPermission (com.google.gerrit.extensions.api.access.PluginPermission)1 IdString (com.google.gerrit.extensions.restapi.IdString)1 ResourceNotFoundException (com.google.gerrit.extensions.restapi.ResourceNotFoundException)1 GlobalPermission (com.google.gerrit.server.permissions.GlobalPermission)1