Rename @CommandMetaData(descr) to description
In e51c428fe5
the metadata was
introduced using the attribute "descr". We do not usually permit
abbreviations in APIs, and especially should not have accepted it
for an API plugins can use.
Mark descr as deprecated so current plugins can migrate. Use
description if available, and fall back to descr for older code.
Change-Id: I662482cd228f81bf1537062b9fe03b6c23354a78
This commit is contained in:

committed by
David Pursehouse

parent
be2d53e50b
commit
5b70c223ba
@@ -357,7 +357,7 @@ this capability in the usual way, using the `RequiresCapability` annotation:
|
||||
|
||||
====
|
||||
@RequiresCapability("printHello")
|
||||
@CommandMetaData(name="print", descr="Print greeting in different languages")
|
||||
@CommandMetaData(name="print", description="Print greeting in different languages")
|
||||
public final class PrintHelloWorldCommand extends SshCommand {
|
||||
...
|
||||
====
|
||||
|
@@ -27,5 +27,9 @@ import java.lang.annotation.Target;
|
||||
@Retention(RUNTIME)
|
||||
public @interface CommandMetaData {
|
||||
String name();
|
||||
String description() default "";
|
||||
|
||||
/** @deprecated use description intead. */
|
||||
@Deprecated
|
||||
String descr() default "";
|
||||
}
|
||||
|
@@ -14,6 +14,8 @@
|
||||
|
||||
package com.google.gerrit.sshd;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.inject.AbstractModule;
|
||||
import com.google.inject.binder.LinkedBindingBuilder;
|
||||
|
||||
@@ -74,7 +76,7 @@ public abstract class CommandModule extends AbstractModule {
|
||||
if (meta == null) {
|
||||
throw new IllegalStateException("no CommandMetaData annotation found");
|
||||
}
|
||||
bind(Commands.key(parent, meta.name(), meta.descr())).to(clazz);
|
||||
bind(Commands.key(parent, meta.name(), description(meta))).to(clazz);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -93,7 +95,13 @@ public abstract class CommandModule extends AbstractModule {
|
||||
if (meta == null) {
|
||||
throw new IllegalStateException("no CommandMetaData annotation found");
|
||||
}
|
||||
bind(Commands.key(parent, name, meta.descr())).to(clazz);
|
||||
bind(Commands.key(parent, name, description(meta))).to(clazz);
|
||||
}
|
||||
|
||||
private static String description(CommandMetaData meta) {
|
||||
return Objects.firstNonNull(
|
||||
Strings.emptyToNull(meta.description()),
|
||||
meta.descr());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -28,7 +28,7 @@ import org.kohsuke.args4j.Option;
|
||||
/** Opens a query processor. */
|
||||
@AdminHighPriorityCommand
|
||||
@RequiresCapability(GlobalCapability.ACCESS_DATABASE)
|
||||
@CommandMetaData(name = "gsql", descr = "Administrative interface to active database")
|
||||
@CommandMetaData(name = "gsql", description = "Administrative interface to active database")
|
||||
final class AdminQueryShell extends SshCommand {
|
||||
@Inject
|
||||
private QueryShell.Factory factory;
|
||||
|
@@ -50,7 +50,7 @@ import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@RequiresCapability(GlobalCapability.ADMINISTRATE_SERVER)
|
||||
@CommandMetaData(name = "set-project-parent", descr = "Change the project permissions are inherited from")
|
||||
@CommandMetaData(name = "set-project-parent", description = "Change the project permissions are inherited from")
|
||||
final class AdminSetParent extends SshCommand {
|
||||
private static final Logger log = LoggerFactory.getLogger(AdminSetParent.class);
|
||||
|
||||
|
@@ -33,7 +33,7 @@ import java.io.PrintWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@CommandMetaData(name = "ban-commit", descr = "Ban a commit from a project's repository")
|
||||
@CommandMetaData(name = "ban-commit", description = "Ban a commit from a project's repository")
|
||||
public class BanCommitCommand extends SshCommand {
|
||||
@Option(name = "--reason", aliases = {"-r"}, metaVar = "REASON", usage = "reason for banning the commit")
|
||||
private String reason;
|
||||
|
@@ -39,7 +39,7 @@ import java.util.List;
|
||||
|
||||
/** Create a new user account. **/
|
||||
@RequiresCapability(GlobalCapability.CREATE_ACCOUNT)
|
||||
@CommandMetaData(name = "create-account", descr = "Create a new batch/role account")
|
||||
@CommandMetaData(name = "create-account", description = "Create a new batch/role account")
|
||||
final class CreateAccountCommand extends SshCommand {
|
||||
@Option(name = "--group", aliases = {"-g"}, metaVar = "GROUP", usage = "groups to add account to")
|
||||
private List<AccountGroup.Id> groups = new ArrayList<AccountGroup.Id>();
|
||||
|
@@ -38,7 +38,7 @@ import java.util.Set;
|
||||
* Optionally, puts an initial set of user in the newly created group.
|
||||
*/
|
||||
@RequiresCapability(GlobalCapability.CREATE_GROUP)
|
||||
@CommandMetaData(name = "create-group", descr = "Create a new account group")
|
||||
@CommandMetaData(name = "create-group", description = "Create a new account group")
|
||||
final class CreateGroupCommand extends SshCommand {
|
||||
@Option(name = "--owner", aliases = {"-o"}, metaVar = "GROUP", usage = "owning group, if not specified the group will be self-owning")
|
||||
private AccountGroup.Id ownerGroupId;
|
||||
|
@@ -36,7 +36,7 @@ import java.util.List;
|
||||
|
||||
/** Create a new project. **/
|
||||
@RequiresCapability(GlobalCapability.CREATE_PROJECT)
|
||||
@CommandMetaData(name = "create-project", descr = "Create a new project and associated Git repository")
|
||||
@CommandMetaData(name = "create-project", description = "Create a new project and associated Git repository")
|
||||
final class CreateProjectCommand extends SshCommand {
|
||||
@Option(name = "--name", aliases = {"-n"}, metaVar = "NAME", usage = "name of project to be created (deprecated option)")
|
||||
void setProjectNameFromOption(String name) {
|
||||
|
@@ -31,7 +31,7 @@ import java.util.SortedSet;
|
||||
|
||||
/** Causes the caches to purge all entries and reload. */
|
||||
@RequiresCapability(GlobalCapability.FLUSH_CACHES)
|
||||
@CommandMetaData(name = "flush-caches", descr = "Flush some/all server caches from memory")
|
||||
@CommandMetaData(name = "flush-caches", description = "Flush some/all server caches from memory")
|
||||
final class FlushCaches extends CacheCommand {
|
||||
private static final String WEB_SESSIONS = "web_sessions";
|
||||
|
||||
|
@@ -37,7 +37,7 @@ import java.util.List;
|
||||
|
||||
/** Runs the Git garbage collection. */
|
||||
@RequiresCapability(GlobalCapability.RUN_GC)
|
||||
@CommandMetaData(name = "gc", descr = "Run Git garbage collection")
|
||||
@CommandMetaData(name = "gc", description = "Run Git garbage collection")
|
||||
public class GarbageCollectionCommand extends BaseCommand {
|
||||
|
||||
@Option(name = "--all", usage = "runs the Git garbage collection for all projects")
|
||||
|
@@ -37,7 +37,7 @@ import org.kohsuke.args4j.Option;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
|
||||
@CommandMetaData(name = "ls-groups", descr = "List groups visible to the caller")
|
||||
@CommandMetaData(name = "ls-groups", description = "List groups visible to the caller")
|
||||
public class ListGroupsCommand extends BaseCommand {
|
||||
@Inject
|
||||
private MyListGroups impl;
|
||||
|
@@ -39,7 +39,7 @@ import javax.inject.Inject;
|
||||
/**
|
||||
* Implements a command that allows the user to see the members of a group.
|
||||
*/
|
||||
@CommandMetaData(name = "ls-members", descr = "Lists the members of a given group")
|
||||
@CommandMetaData(name = "ls-members", description = "Lists the members of a given group")
|
||||
public class ListMembersCommand extends BaseCommand {
|
||||
@Inject
|
||||
ListMembersCommandImpl impl;
|
||||
|
@@ -23,7 +23,7 @@ import org.apache.sshd.server.Environment;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@CommandMetaData(name = "ls-projects", descr = "List projects visible to the caller")
|
||||
@CommandMetaData(name = "ls-projects", description = "List projects visible to the caller")
|
||||
final class ListProjectsCommand extends BaseCommand {
|
||||
@Inject
|
||||
private ListProjects impl;
|
||||
|
@@ -40,7 +40,7 @@ import java.io.IOException;
|
||||
import java.util.Map;
|
||||
|
||||
@RequiresCapability(GlobalCapability.ADMINISTRATE_SERVER)
|
||||
@CommandMetaData(name = "ls-user-refs", descr = "List refs visible to a specific user")
|
||||
@CommandMetaData(name = "ls-user-refs", description = "List refs visible to a specific user")
|
||||
public class LsUserRefs extends SshCommand {
|
||||
@Inject
|
||||
private AccountResolver accountResolver;
|
||||
|
@@ -28,7 +28,7 @@ import org.kohsuke.args4j.Argument;
|
||||
import java.util.List;
|
||||
|
||||
@RequiresCapability(GlobalCapability.ADMINISTRATE_SERVER)
|
||||
@CommandMetaData(name = "enable", descr = "Enable plugins")
|
||||
@CommandMetaData(name = "enable", description = "Enable plugins")
|
||||
final class PluginEnableCommand extends SshCommand {
|
||||
@Argument(index = 0, metaVar = "NAME", required = true, usage = "plugin(s) to enable")
|
||||
List<String> names;
|
||||
|
@@ -35,7 +35,7 @@ import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
|
||||
@RequiresCapability(GlobalCapability.ADMINISTRATE_SERVER)
|
||||
@CommandMetaData(name = "install", descr = "Install/Add a plugin")
|
||||
@CommandMetaData(name = "install", description = "Install/Add a plugin")
|
||||
final class PluginInstallCommand extends SshCommand {
|
||||
@Option(name = "--name", aliases = {"-n"}, usage = "install under name")
|
||||
private String name;
|
||||
|
@@ -26,7 +26,7 @@ import org.apache.sshd.server.Environment;
|
||||
import java.io.IOException;
|
||||
|
||||
@RequiresCapability(GlobalCapability.ADMINISTRATE_SERVER)
|
||||
@CommandMetaData(name = "ls", descr = "List the installed plugins")
|
||||
@CommandMetaData(name = "ls", description = "List the installed plugins")
|
||||
final class PluginLsCommand extends BaseCommand {
|
||||
@Inject
|
||||
private ListPlugins impl;
|
||||
|
@@ -28,7 +28,7 @@ import org.kohsuke.args4j.Argument;
|
||||
import java.util.List;
|
||||
|
||||
@RequiresCapability(GlobalCapability.ADMINISTRATE_SERVER)
|
||||
@CommandMetaData(name = "reload", descr = "Reload/Restart plugins")
|
||||
@CommandMetaData(name = "reload", description = "Reload/Restart plugins")
|
||||
final class PluginReloadCommand extends SshCommand {
|
||||
@Argument(index = 0, metaVar = "NAME", usage = "plugins to reload/restart")
|
||||
private List<String> names;
|
||||
|
@@ -27,7 +27,7 @@ import org.kohsuke.args4j.Argument;
|
||||
import java.util.List;
|
||||
|
||||
@RequiresCapability(GlobalCapability.ADMINISTRATE_SERVER)
|
||||
@CommandMetaData(name = "remove", descr = "Disable plugins")
|
||||
@CommandMetaData(name = "remove", description = "Disable plugins")
|
||||
final class PluginRemoveCommand extends SshCommand {
|
||||
@Argument(index = 0, metaVar = "NAME", required = true, usage = "plugin to remove")
|
||||
List<String> names;
|
||||
|
@@ -24,7 +24,7 @@ import org.kohsuke.args4j.Option;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@CommandMetaData(name = "query", descr = "Query the change database")
|
||||
@CommandMetaData(name = "query", description = "Query the change database")
|
||||
class Query extends SshCommand {
|
||||
@Inject
|
||||
private QueryProcessor processor;
|
||||
|
@@ -42,7 +42,7 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/** Receives change upload over SSH using the Git receive-pack protocol. */
|
||||
@CommandMetaData(name = "receive-pack", descr = "Standard Git server side command for client side git push")
|
||||
@CommandMetaData(name = "receive-pack", description = "Standard Git server side command for client side git push")
|
||||
final class Receive extends AbstractGitCommand {
|
||||
private static final Logger log = LoggerFactory.getLogger(Receive.class);
|
||||
|
||||
|
@@ -25,7 +25,7 @@ import com.google.inject.Inject;
|
||||
|
||||
import org.kohsuke.args4j.Argument;
|
||||
|
||||
@CommandMetaData(name = "rename-group", descr = "Rename an account group")
|
||||
@CommandMetaData(name = "rename-group", description = "Rename an account group")
|
||||
public class RenameGroupCommand extends SshCommand {
|
||||
@Argument(index = 0, required = true, metaVar = "GROUP", usage = "name of the group to be renamed")
|
||||
private String groupName;
|
||||
|
@@ -63,7 +63,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
@CommandMetaData(name = "review", descr = "Verify, approve and/or submit one or more patch sets")
|
||||
@CommandMetaData(name = "review", description = "Verify, approve and/or submit one or more patch sets")
|
||||
public class ReviewCommand extends SshCommand {
|
||||
private static final Logger log =
|
||||
LoggerFactory.getLogger(ReviewCommand.class);
|
||||
|
@@ -55,7 +55,7 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/** Set a user's account settings. **/
|
||||
@CommandMetaData(name = "set-account", descr = "Change an account's settings")
|
||||
@CommandMetaData(name = "set-account", description = "Change an account's settings")
|
||||
final class SetAccountCommand extends BaseCommand {
|
||||
|
||||
@Argument(index = 0, required = true, metaVar = "USER", usage = "full name, email-address, ssh username or account id")
|
||||
|
@@ -43,7 +43,7 @@ import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.List;
|
||||
|
||||
@CommandMetaData(name = "set-members", descr = "Modifies members of specific group or number of groups")
|
||||
@CommandMetaData(name = "set-members", description = "Modifies members of specific group or number of groups")
|
||||
public class SetMembersCommand extends SshCommand {
|
||||
|
||||
@Option(name = "--add", aliases = {"-a"}, metaVar = "USER", usage = "users that should be added as group member")
|
||||
|
@@ -38,7 +38,7 @@ import org.slf4j.LoggerFactory;
|
||||
import java.io.IOException;
|
||||
|
||||
@RequiresCapability(GlobalCapability.ADMINISTRATE_SERVER)
|
||||
@CommandMetaData(name = "set-project", descr = "Change a project's settings")
|
||||
@CommandMetaData(name = "set-project", description = "Change a project's settings")
|
||||
final class SetProjectCommand extends SshCommand {
|
||||
private static final Logger log = LoggerFactory
|
||||
.getLogger(SetProjectCommand.class);
|
||||
|
@@ -45,7 +45,7 @@ import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@CommandMetaData(name = "set-reviewers", descr = "Add or remove reviewers on a change")
|
||||
@CommandMetaData(name = "set-reviewers", description = "Add or remove reviewers on a change")
|
||||
public class SetReviewersCommand extends SshCommand {
|
||||
private static final Logger log =
|
||||
LoggerFactory.getLogger(SetReviewersCommand.class);
|
||||
|
@@ -52,7 +52,7 @@ import java.util.SortedMap;
|
||||
|
||||
/** Show the current cache states. */
|
||||
@RequiresCapability(GlobalCapability.VIEW_CACHES)
|
||||
@CommandMetaData(name = "show-caches", descr = "Display current cache statistics")
|
||||
@CommandMetaData(name = "show-caches", description = "Display current cache statistics")
|
||||
final class ShowCaches extends CacheCommand {
|
||||
private static volatile long serverStarted;
|
||||
|
||||
|
@@ -44,7 +44,7 @@ import java.util.List;
|
||||
|
||||
/** Show the current SSH connections. */
|
||||
@RequiresCapability(GlobalCapability.VIEW_CONNECTIONS)
|
||||
@CommandMetaData(name = "show-connections", descr = "Display active client SSH connections")
|
||||
@CommandMetaData(name = "show-connections", description = "Display active client SSH connections")
|
||||
final class ShowConnections extends SshCommand {
|
||||
@Option(name = "--numeric", aliases = {"-n"}, usage = "don't resolve names")
|
||||
private boolean numeric;
|
||||
|
@@ -40,7 +40,7 @@ import java.util.concurrent.TimeUnit;
|
||||
|
||||
/** Display the current work queue. */
|
||||
@AdminHighPriorityCommand
|
||||
@CommandMetaData(name = "show-queue", descr = "Display the background work queues, including replication")
|
||||
@CommandMetaData(name = "show-queue", description = "Display the background work queues, including replication")
|
||||
final class ShowQueue extends SshCommand {
|
||||
@Option(name = "--wide", aliases = {"-w"}, usage = "display without line width truncation")
|
||||
private boolean wide;
|
||||
|
@@ -36,7 +36,7 @@ import java.util.concurrent.Future;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
|
||||
@RequiresCapability(GlobalCapability.STREAM_EVENTS)
|
||||
@CommandMetaData(name = "stream-events", descr = "Monitor events occurring in real time")
|
||||
@CommandMetaData(name = "stream-events", description = "Monitor events occurring in real time")
|
||||
final class StreamEvents extends BaseCommand {
|
||||
/** Maximum number of events that may be queued up for each connection. */
|
||||
private static final int MAX_EVENTS = 128;
|
||||
|
@@ -23,7 +23,7 @@ import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
|
||||
/** Command that allows testing of prolog submit-rules in a live instance. */
|
||||
@CommandMetaData(name = "rule", descr = "Test prolog submit rules")
|
||||
@CommandMetaData(name = "rule", description = "Test prolog submit rules")
|
||||
final class TestSubmitRuleCommand extends BaseTestPrologCommand {
|
||||
@Inject
|
||||
private Provider<TestSubmitRule> view;
|
||||
|
@@ -23,7 +23,7 @@ import com.google.gerrit.sshd.CommandMetaData;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
|
||||
@CommandMetaData(name = "type", descr = "Test prolog submit type")
|
||||
@CommandMetaData(name = "type", description = "Test prolog submit type")
|
||||
final class TestSubmitTypeCommand extends BaseTestPrologCommand {
|
||||
@Inject
|
||||
private Provider<TestSubmitType> view;
|
||||
|
@@ -18,7 +18,7 @@ import com.google.gerrit.common.Version;
|
||||
import com.google.gerrit.sshd.CommandMetaData;
|
||||
import com.google.gerrit.sshd.SshCommand;
|
||||
|
||||
@CommandMetaData(name = "version", descr = "Display gerrit version")
|
||||
@CommandMetaData(name = "version", description = "Display gerrit version")
|
||||
final class VersionCommand extends SshCommand {
|
||||
|
||||
@Override
|
||||
|
Reference in New Issue
Block a user