Search in sources :

Example 1 with PluginPermission

use of com.google.gerrit.extensions.api.access.PluginPermission in project gerrit by GerritCodeReview.

the class Capabilities method parse.

private GlobalOrPluginPermission parse(IdString id) throws ResourceNotFoundException {
    String name = id.get();
    GlobalOrPluginPermission perm = GlobalPermission.byName(name);
    if (perm != null) {
        return perm;
    }
    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) IdString(com.google.gerrit.extensions.restapi.IdString) ResourceNotFoundException(com.google.gerrit.extensions.restapi.ResourceNotFoundException) GlobalOrPluginPermission(com.google.gerrit.extensions.api.access.GlobalOrPluginPermission)

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