Merge branch 'stable-2.10'

* stable-2.10:
  Consume API version 2.10

Merge made by the 'ours' strategy.

Change-Id: Id8754b611c09063e0afd76911085199e72409f0a
diff --git a/.buckconfig b/.buckconfig
new file mode 100644
index 0000000..006f131
--- /dev/null
+++ b/.buckconfig
@@ -0,0 +1,8 @@
+[alias]
+  plugin = //:serviceuser
+
+[java]
+  src_roots = java, resources
+
+[project]
+  ignore = .git
diff --git a/.gitignore b/.gitignore
index 3f04530..3a5e3a4 100644
--- a/.gitignore
+++ b/.gitignore
@@ -5,3 +5,7 @@
 /.settings/org.maven.ide.eclipse.prefs
 /.settings/org.eclipse.m2e.core.prefs
 /.idea
+.buckd
+.buckversion
+buck-out
+bucklets
diff --git a/BUCK b/BUCK
index 916dc21..75587f1 100644
--- a/BUCK
+++ b/BUCK
@@ -1,3 +1,4 @@
+include_defs('//bucklets/gerrit_plugin.bucklet')
 MODULE = 'com.googlesource.gerrit.plugins.serviceuser.CreateServiceUserForm'
 
 gerrit_plugin(
@@ -11,10 +12,9 @@
     'Gerrit-HttpModule: com.googlesource.gerrit.plugins.serviceuser.HttpModule',
     'Gerrit-SshModule: com.googlesource.gerrit.plugins.serviceuser.SshModule',
   ],
-  provided_deps = [
-    '//gerrit-gwtexpui:Clippy',
-    '//gerrit-gwtexpui:GlobalKey',
-    '//gerrit-gwtexpui:SafeHtml',
-    '//gerrit-gwtexpui:UserAgent',
-  ]
+)
+
+java_library(
+  name = 'classpath',
+  deps = [':serviceuser__plugin'],
 )
diff --git a/VERSION b/VERSION
new file mode 100644
index 0000000..b9fbaf5
--- /dev/null
+++ b/VERSION
@@ -0,0 +1,4 @@
+# Used by BUCK to include "Implementation-Version" in plugin Manifest.
+# If this file doesn't exist the output of 'git describe' is used
+# instead.
+PLUGIN_VERSION = '2.11-SNAPSHOT'
diff --git a/lib/gerrit/BUCK b/lib/gerrit/BUCK
new file mode 100644
index 0000000..9e15e4d
--- /dev/null
+++ b/lib/gerrit/BUCK
@@ -0,0 +1,21 @@
+include_defs('//bucklets/maven_jar.bucklet')
+
+VER = '2.11-SNAPSHOT'
+REPO = MAVEN_LOCAL
+
+maven_jar(
+  name = 'plugin-api',
+  id = 'com.google.gerrit:gerrit-plugin-api:' + VER,
+  attach_source = False,
+  repository = REPO,
+  license = 'Apache2.0',
+)
+
+maven_jar(
+  name = 'gwtui-api',
+  id = 'com.google.gerrit:gerrit-plugin-gwtui:' + VER,
+  attach_source = False,
+  repository = REPO,
+  license = 'Apache2.0',
+)
+
diff --git a/lib/gwt/BUCK b/lib/gwt/BUCK
new file mode 100644
index 0000000..2968cb7
--- /dev/null
+++ b/lib/gwt/BUCK
@@ -0,0 +1,33 @@
+include_defs('//bucklets/maven_jar.bucklet')
+
+VERSION = '2.6.1'
+
+maven_jar(
+  name = 'user',
+  id = 'com.google.gwt:gwt-user:' + VERSION,
+  sha1 = 'c078b1b8cc0281214b0eb458d2c283d039374fad',
+  license = 'Apache2.0',
+  attach_source = False,
+)
+
+maven_jar(
+  name = 'dev',
+  id = 'com.google.gwt:gwt-dev:' + VERSION,
+  sha1 = 'db237e4be0aa1fe43425d2c51ab5485dba211ddd',
+  license = 'Apache2.0',
+  deps = [
+    ':javax-validation',
+    ':javax-validation_src',
+  ],
+  attach_source = False,
+  exclude = ['org/eclipse/jetty/*'],
+)
+
+maven_jar(
+  name = 'javax-validation',
+  id = 'javax.validation:validation-api:1.0.0.GA',
+  bin_sha1 = 'b6bd7f9d78f6fdaa3c37dae18a4bd298915f328e',
+  src_sha1 = '7a561191db2203550fbfa40d534d4997624cd369',
+  license = 'Apache2.0',
+  visibility = [],
+)
diff --git a/pom.xml b/pom.xml
index fee494d..6c342c4 100644
--- a/pom.xml
+++ b/pom.xml
@@ -26,7 +26,7 @@
 
   <properties>
     <Gerrit-ApiType>plugin</Gerrit-ApiType>
-    <Gerrit-ApiVersion>2.10</Gerrit-ApiVersion>
+    <Gerrit-ApiVersion>2.11-SNAPSHOT</Gerrit-ApiVersion>
   </properties>
 
   <build>
@@ -73,7 +73,7 @@
       <plugin>
         <groupId>org.codehaus.mojo</groupId>
         <artifactId>gwt-maven-plugin</artifactId>
-        <version>2.6.1</version>
+        <version>2.7.0</version>
         <configuration>
           <module>com.googlesource.gerrit.plugins.serviceuser.CreateServiceUserForm</module>
           <disableClassMetadata>true</disableClassMetadata>
@@ -108,28 +108,8 @@
     <dependency>
       <groupId>com.google.gwt</groupId>
       <artifactId>gwt-user</artifactId>
-      <version>2.6.1</version>
+      <version>2.7.0</version>
       <scope>provided</scope>
     </dependency>
-
-    <dependency>
-      <groupId>gwtexpui</groupId>
-      <artifactId>gwtexpui</artifactId>
-      <version>1.3.4</version>
-      <scope>provided</scope>
-    </dependency>
-    <dependency>
-      <groupId>gwtexpui</groupId>
-      <artifactId>gwtexpui</artifactId>
-      <version>1.3.4</version>
-      <classifier>sources</classifier>
-    </dependency>
   </dependencies>
-
-  <repositories>
-    <repository>
-      <id>gerrit-maven-repository</id>
-      <url>https://gerrit-maven.storage.googleapis.com/</url>
-    </repository>
-  </repositories>
 </project>
diff --git a/src/main/java/com/googlesource/gerrit/plugins/serviceuser/CreateServiceUser.java b/src/main/java/com/googlesource/gerrit/plugins/serviceuser/CreateServiceUser.java
index b0ebf64..c1684d8 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/serviceuser/CreateServiceUser.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/serviceuser/CreateServiceUser.java
@@ -17,8 +17,10 @@
 import com.google.common.base.Function;
 import com.google.common.base.Strings;
 import com.google.common.collect.Lists;
+import com.google.gerrit.common.TimeUtil;
 import com.google.gerrit.extensions.annotations.PluginName;
 import com.google.gerrit.extensions.annotations.RequiresCapability;
+import com.google.gerrit.extensions.common.AccountInfo;
 import com.google.gerrit.extensions.restapi.AuthException;
 import com.google.gerrit.extensions.restapi.BadRequestException;
 import com.google.gerrit.extensions.restapi.ResourceConflictException;
@@ -36,7 +38,7 @@
 import com.google.gerrit.server.GerritPersonIdent;
 import com.google.gerrit.server.IdentifiedUser;
 import com.google.gerrit.server.account.AccountCache;
-import com.google.gerrit.server.account.AccountInfo;
+import com.google.gerrit.server.account.AccountLoader;
 import com.google.gerrit.server.account.CreateAccount;
 import com.google.gerrit.server.account.GroupCache;
 import com.google.gerrit.server.config.ConfigResource;
@@ -45,7 +47,6 @@
 import com.google.gerrit.server.git.MetaDataUpdate;
 import com.google.gerrit.server.git.ProjectLevelConfig;
 import com.google.gerrit.server.project.ProjectCache;
-import com.google.gerrit.server.util.TimeUtil;
 import com.google.gwtorm.server.OrmException;
 import com.google.inject.Inject;
 import com.google.inject.Provider;
@@ -104,7 +105,7 @@
   private final ProjectLevelConfig storage;
   private final DateFormat rfc2822DateFormatter;
   private final Provider<GetConfig> getConfig;
-  private final AccountInfo.Loader.Factory accountLoader;
+  private final AccountLoader.Factory accountLoader;
 
   @Inject
   CreateServiceUser(PluginConfigFactory cfgFactory,
@@ -120,7 +121,7 @@
       ProjectCache projectCache,
       @Assisted String username,
       Provider<GetConfig> getConfig,
-      AccountInfo.Loader.Factory accountLoader) {
+      AccountLoader.Factory accountLoader) {
     this.cfg = cfgFactory.getFromGerritConfig(pluginName);
     this.createAccountFactory = createAccountFactory;
     this.groupCache = groupCache;
@@ -184,7 +185,9 @@
         new ServiceUserInput(username, input.email, input.sshKey);
     Response<AccountInfo> response =
         createAccountFactory.create(username).apply(TopLevelResource.INSTANCE, in);
-    addToGroups(response.value()._id, cfg.getStringList("group"));
+
+    addToGroups(new Account.Id(response.value()._accountId),
+        cfg.getStringList("group"));
 
     String creator = user.getUserName();
     Account.Id creatorId = ((IdentifiedUser)user).getAccountId();
@@ -202,7 +205,7 @@
     storage.commit(md);
 
     ServiceUserInfo info = new ServiceUserInfo(response.value());
-    AccountInfo.Loader al = accountLoader.create(true);
+    AccountLoader al = accountLoader.create(true);
     info.createdBy = al.get(creatorId);
     al.fill();
     info.createdAt = creationDate;
diff --git a/src/main/java/com/googlesource/gerrit/plugins/serviceuser/CreateServiceUserNotes.java b/src/main/java/com/googlesource/gerrit/plugins/serviceuser/CreateServiceUserNotes.java
index 86d53a4..006e2b6 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/serviceuser/CreateServiceUserNotes.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/serviceuser/CreateServiceUserNotes.java
@@ -17,9 +17,9 @@
 import static com.googlesource.gerrit.plugins.serviceuser.CreateServiceUser.KEY_CREATED_BY;
 import static com.googlesource.gerrit.plugins.serviceuser.CreateServiceUser.KEY_OWNER;
 
+import com.google.gerrit.extensions.common.AccountInfo;
 import com.google.gerrit.reviewdb.client.Project;
 import com.google.gerrit.server.GerritPersonIdent;
-import com.google.gerrit.server.account.AccountInfo;
 import com.google.gerrit.server.config.AnonymousCowardName;
 import com.google.gerrit.server.git.NotesBranchUtil;
 import com.google.gwtorm.server.OrmException;
diff --git a/src/main/java/com/googlesource/gerrit/plugins/serviceuser/DeleteSshKey.java b/src/main/java/com/googlesource/gerrit/plugins/serviceuser/DeleteSshKey.java
index 5823cf2..e7e0340 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/serviceuser/DeleteSshKey.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/serviceuser/DeleteSshKey.java
@@ -14,6 +14,7 @@
 
 package com.googlesource.gerrit.plugins.serviceuser;
 
+import com.google.gerrit.extensions.restapi.AuthException;
 import com.google.gerrit.extensions.restapi.Response;
 import com.google.gerrit.extensions.restapi.RestModifyView;
 import com.google.gerrit.server.account.AccountResource;
@@ -35,7 +36,7 @@
 
   @Override
   public Response<?> apply(ServiceUserResource.SshKey rsrc, Input input)
-      throws OrmException {
+      throws OrmException, AuthException {
     return deleteSshKey.get().apply(
         new AccountResource.SshKey(rsrc.getUser(), rsrc.getSshKey()), input);
   }
diff --git a/src/main/java/com/googlesource/gerrit/plugins/serviceuser/GetServiceUser.java b/src/main/java/com/googlesource/gerrit/plugins/serviceuser/GetServiceUser.java
index 497bc47..22f3afd 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/serviceuser/GetServiceUser.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/serviceuser/GetServiceUser.java
@@ -20,11 +20,12 @@
 import static javax.servlet.http.HttpServletResponse.SC_OK;
 
 import com.google.gerrit.extensions.annotations.PluginName;
+import com.google.gerrit.extensions.common.AccountInfo;
 import com.google.gerrit.extensions.restapi.ResourceNotFoundException;
 import com.google.gerrit.extensions.restapi.Response;
 import com.google.gerrit.extensions.restapi.RestReadView;
 import com.google.gerrit.reviewdb.client.Account;
-import com.google.gerrit.server.account.AccountInfo;
+import com.google.gerrit.server.account.AccountLoader;
 import com.google.gerrit.server.account.GetAccount;
 import com.google.gerrit.server.git.ProjectLevelConfig;
 import com.google.gerrit.server.group.GroupJson.GroupInfo;
@@ -42,12 +43,12 @@
   private final String pluginName;
   private final ProjectCache projectCache;
   private final GetOwner getOwner;
-  private final AccountInfo.Loader.Factory accountLoader;
+  private final AccountLoader.Factory accountLoader;
 
   @Inject
   GetServiceUser(Provider<GetAccount> getAccount,
       @PluginName String pluginName, ProjectCache projectCache,
-      GetOwner getOwner, AccountInfo.Loader.Factory accountLoader) {
+      GetOwner getOwner, AccountLoader.Factory accountLoader) {
     this.getAccount = getAccount;
     this.pluginName = pluginName;
     this.projectCache = projectCache;
@@ -66,7 +67,7 @@
     }
 
     ServiceUserInfo info = new ServiceUserInfo(getAccount.get().apply(rsrc));
-    AccountInfo.Loader al = accountLoader.create(true);
+    AccountLoader al = accountLoader.create(true);
     info.createdBy =
         al.get(new Account.Id(db.getInt(USER, username, KEY_CREATOR_ID, -1)));
     al.fill();
@@ -88,7 +89,7 @@
     public GroupInfo owner;
 
     public ServiceUserInfo(AccountInfo info) {
-      super(info._id);
+      super(info._accountId);
       _accountId = info._accountId;
       name = info.name;
       email = info.email;
diff --git a/src/main/java/com/googlesource/gerrit/plugins/serviceuser/HeaderFormatter.java b/src/main/java/com/googlesource/gerrit/plugins/serviceuser/HeaderFormatter.java
index 157d7d7..44bc973 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/serviceuser/HeaderFormatter.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/serviceuser/HeaderFormatter.java
@@ -15,7 +15,7 @@
 package com.googlesource.gerrit.plugins.serviceuser;
 
 import com.google.common.base.Strings;
-import com.google.gerrit.server.account.AccountInfo;
+import com.google.gerrit.extensions.common.AccountInfo;
 
 import java.text.DateFormat;
 import java.text.SimpleDateFormat;
@@ -71,7 +71,7 @@
     }
 
     if (!wroteData) {
-      sb.append(anonymousCowardName).append(" #").append(user._id.get());
+      sb.append(anonymousCowardName).append(" #").append(user._accountId);
     }
   }
 
diff --git a/src/main/java/com/googlesource/gerrit/plugins/serviceuser/Module.java b/src/main/java/com/googlesource/gerrit/plugins/serviceuser/Module.java
index f1c2618..66dd394 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/serviceuser/Module.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/serviceuser/Module.java
@@ -16,7 +16,7 @@
 
 import static com.google.gerrit.server.config.ConfigResource.CONFIG_KIND;
 import static com.googlesource.gerrit.plugins.serviceuser.ServiceUserResource.SERVICE_USER_KIND;
-import static com.googlesource.gerrit.plugins.serviceuser.ServiceUserResource.SSH_KEY_KIND;
+import static com.googlesource.gerrit.plugins.serviceuser.ServiceUserResource.SERVICE_USER_SSH_KEY_KIND;
 
 import com.google.gerrit.extensions.annotations.Exports;
 import com.google.gerrit.extensions.config.CapabilityDefinition;
@@ -46,7 +46,7 @@
       @Override
       protected void configure() {
         DynamicMap.mapOf(binder(), SERVICE_USER_KIND);
-        DynamicMap.mapOf(binder(), SSH_KEY_KIND);
+        DynamicMap.mapOf(binder(), SERVICE_USER_SSH_KEY_KIND);
         bind(ServiceUserCollection.class);
         child(CONFIG_KIND, "serviceusers").to(ServiceUserCollection.class);
         get(SERVICE_USER_KIND).to(GetServiceUser.class);
@@ -54,9 +54,9 @@
         get(CONFIG_KIND, "config").to(GetConfig.class);
         put(CONFIG_KIND, "config").to(PutConfig.class);
         child(SERVICE_USER_KIND, "sshkeys").to(SshKeys.class);
-        get(SSH_KEY_KIND).to(GetSshKey.class);
+        get(SERVICE_USER_SSH_KEY_KIND).to(GetSshKey.class);
         post(SERVICE_USER_KIND, "sshkeys").to(AddSshKey.class);
-        delete(SSH_KEY_KIND).to(DeleteSshKey.class);
+        delete(SERVICE_USER_SSH_KEY_KIND).to(DeleteSshKey.class);
         get(SERVICE_USER_KIND, "name").to(GetName.class);
         put(SERVICE_USER_KIND, "name").to(PutName.class);
         delete(SERVICE_USER_KIND, "name").to(PutName.class);
diff --git a/src/main/java/com/googlesource/gerrit/plugins/serviceuser/PutConfig.java b/src/main/java/com/googlesource/gerrit/plugins/serviceuser/PutConfig.java
index 7a8ee84..4986cec 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/serviceuser/PutConfig.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/serviceuser/PutConfig.java
@@ -60,8 +60,7 @@
 
   @Inject
   PutConfig(PluginConfigFactory cfgFactory, SitePaths sitePaths,
-      @PluginName String pluginName, GroupCache groupCache) throws IOException,
-      ConfigInvalidException {
+      @PluginName String pluginName, GroupCache groupCache) {
     this.cfgFactory = cfgFactory;
     this.sitePaths = sitePaths;
     this.pluginName = pluginName;
diff --git a/src/main/java/com/googlesource/gerrit/plugins/serviceuser/PutOwner.java b/src/main/java/com/googlesource/gerrit/plugins/serviceuser/PutOwner.java
index f411dfc..6201514 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/serviceuser/PutOwner.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/serviceuser/PutOwner.java
@@ -14,8 +14,8 @@
 
 package com.googlesource.gerrit.plugins.serviceuser;
 
-import static com.googlesource.gerrit.plugins.serviceuser.CreateServiceUser.USER;
 import static com.googlesource.gerrit.plugins.serviceuser.CreateServiceUser.KEY_OWNER;
+import static com.googlesource.gerrit.plugins.serviceuser.CreateServiceUser.USER;
 
 import com.google.common.base.Strings;
 import com.google.gerrit.common.data.GroupDescription;
@@ -32,8 +32,8 @@
 import com.google.gerrit.server.config.ConfigResource;
 import com.google.gerrit.server.git.MetaDataUpdate;
 import com.google.gerrit.server.git.ProjectLevelConfig;
-import com.google.gerrit.server.group.GroupJson.GroupInfo;
 import com.google.gerrit.server.group.GroupJson;
+import com.google.gerrit.server.group.GroupJson.GroupInfo;
 import com.google.gerrit.server.group.GroupsCollection;
 import com.google.gerrit.server.project.ProjectCache;
 import com.google.gwtorm.server.OrmException;
diff --git a/src/main/java/com/googlesource/gerrit/plugins/serviceuser/ServiceUserResolver.java b/src/main/java/com/googlesource/gerrit/plugins/serviceuser/ServiceUserResolver.java
index 7f60c4a..fea4548 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/serviceuser/ServiceUserResolver.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/serviceuser/ServiceUserResolver.java
@@ -14,7 +14,7 @@
 
 package com.googlesource.gerrit.plugins.serviceuser;
 
-import com.google.gerrit.extensions.restapi.MethodNotAllowedException;
+import com.google.gerrit.extensions.common.AccountInfo;
 import com.google.gerrit.extensions.restapi.ResourceNotFoundException;
 import com.google.gerrit.reviewdb.client.Account;
 import com.google.gerrit.reviewdb.client.AccountGroup;
@@ -24,7 +24,6 @@
 import com.google.gerrit.server.CurrentUser;
 import com.google.gerrit.server.IdentifiedUser;
 import com.google.gerrit.server.account.AccountCache;
-import com.google.gerrit.server.account.AccountInfo;
 import com.google.gerrit.server.account.AccountResolver;
 import com.google.gerrit.server.account.AccountState;
 import com.google.gerrit.server.account.GroupMembership;
@@ -40,8 +39,6 @@
 import com.googlesource.gerrit.plugins.serviceuser.GetServiceUser.ServiceUserInfo;
 
 import org.eclipse.jgit.lib.PersonIdent;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 import java.util.ArrayList;
 import java.util.Collection;
@@ -51,9 +48,6 @@
 
 @Singleton
 class ServiceUserResolver {
-  private static final Logger log =
-      LoggerFactory.getLogger(ServiceUserResolver.class);
-
   private final AccountResolver resolver;
   private final IdentifiedUser.GenericFactory genericUserFactory;
   private final Provider<GetServiceUser> getServiceUser;
@@ -164,10 +158,6 @@
           owners.add(a);
         }
         return owners;
-      } catch (MethodNotAllowedException e) {
-        log.error(String.format("Failed to list members of owner group %s for service user %s.",
-            serviceUser.owner.name, serviceUser.username));
-        return Collections.emptyList();
       } finally {
         tl.setContext(old);
       }
@@ -180,7 +170,7 @@
       throws OrmException {
     List<AccountInfo> activeOwners = new ArrayList<>();
     for (AccountInfo owner : listOwners(serviceUser)) {
-      AccountState accountState = accountCache.get(owner._id);
+      AccountState accountState = accountCache.get(new Account.Id(owner._accountId));
       if (accountState != null && accountState.getAccount().isActive()) {
         activeOwners.add(owner);
       }
diff --git a/src/main/java/com/googlesource/gerrit/plugins/serviceuser/ServiceUserResource.java b/src/main/java/com/googlesource/gerrit/plugins/serviceuser/ServiceUserResource.java
index 6d9d4ec..2a37815 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/serviceuser/ServiceUserResource.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/serviceuser/ServiceUserResource.java
@@ -24,7 +24,7 @@
   static final TypeLiteral<RestView<ServiceUserResource>> SERVICE_USER_KIND =
       new TypeLiteral<RestView<ServiceUserResource>>() {};
 
-  static final TypeLiteral<RestView<SshKey>> SSH_KEY_KIND =
+  static final TypeLiteral<RestView<SshKey>> SERVICE_USER_SSH_KEY_KIND =
       new TypeLiteral<RestView<SshKey>>() {};
 
   ServiceUserResource(IdentifiedUser user) {
diff --git a/src/main/java/com/googlesource/gerrit/plugins/serviceuser/ValidateServiceUserCommits.java b/src/main/java/com/googlesource/gerrit/plugins/serviceuser/ValidateServiceUserCommits.java
index 44c2d15..c0684e7 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/serviceuser/ValidateServiceUserCommits.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/serviceuser/ValidateServiceUserCommits.java
@@ -14,6 +14,7 @@
 
 package com.googlesource.gerrit.plugins.serviceuser;
 
+import com.google.gerrit.reviewdb.client.Account;
 import com.google.gerrit.server.account.AccountCache;
 import com.google.gerrit.server.account.AccountState;
 import com.google.gerrit.server.events.CommitReceivedEvent;
@@ -59,7 +60,8 @@
               receiveEvent.commit.getId().getName(), committer.getName(),
               committer.getEmailAddress()));
         } else {
-          AccountState creator = accountCache.get(serviceUser.createdBy._id);
+          AccountState creator = accountCache.get(
+              new Account.Id(serviceUser.createdBy._accountId));
           if (creator == null || !creator.getAccount().isActive()) {
             throw new CommitValidationException(String.format(
                 "Commit %s of service user %s (%s) is rejected because "
diff --git a/src/main/java/com/googlesource/gerrit/plugins/serviceuser/client/CreateServiceUserScreen.java b/src/main/java/com/googlesource/gerrit/plugins/serviceuser/client/CreateServiceUserScreen.java
index ae600e7..65ce461 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/serviceuser/client/CreateServiceUserScreen.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/serviceuser/client/CreateServiceUserScreen.java
@@ -195,6 +195,7 @@
         p.add(new Label("The service user '" + username + "' was created."));
         Button okButton = new Button("OK");
         okButton.addClickHandler(new ClickHandler() {
+          @Override
           public void onClick(ClickEvent event) {
             successDialog.hide();
           }
diff --git a/src/main/java/com/googlesource/gerrit/plugins/serviceuser/client/OnEditEnabler.java b/src/main/java/com/googlesource/gerrit/plugins/serviceuser/client/OnEditEnabler.java
index ecfee9f..233ca30 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/serviceuser/client/OnEditEnabler.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/serviceuser/client/OnEditEnabler.java
@@ -46,11 +46,11 @@
    MouseUpHandler, ChangeHandler, ValueChangeHandler<Object> {
 
   private final FocusWidget widget;
-  private Map<TextBoxBase, String> strings = new HashMap<TextBoxBase, String>();
+  private Map<TextBoxBase, String> strings = new HashMap<>();
   private String originalValue;
 
 
-  // The first parameter to the contructors must be the FocusWidget to enable,
+  // The first parameter to the constructors must be the FocusWidget to enable,
   // subsequent parameters are widgets to listenTo.
 
   public OnEditEnabler(final FocusWidget w, final TextBoxBase tb) {
diff --git a/src/main/java/com/googlesource/gerrit/plugins/serviceuser/client/SshPanel.java b/src/main/java/com/googlesource/gerrit/plugins/serviceuser/client/SshPanel.java
index 53db9e9..7764554 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/serviceuser/client/SshPanel.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/serviceuser/client/SshPanel.java
@@ -156,6 +156,7 @@
       new RestApi("config").id("server")
           .view(Plugin.get().getPluginName(), "serviceusers").id(serviceUser)
           .view("sshkeys").post(txt, new AsyncCallback<SshKeyInfo>() {
+        @Override
         public void onSuccess(SshKeyInfo k) {
           addTxt.setText("");
           keys.addOneKey(k);
@@ -215,7 +216,7 @@
     private ValueChangeHandler<Boolean> updateDeleteHandler;
 
     SshKeyTable() {
-      this.sshKeyInfos = new HashMap<Integer, SshKeyInfo>();
+      this.sshKeyInfos = new HashMap<>();
       setStyleName("serviceuser-sshKeyTable");
       setWidth("");
       setText(0, 2, "Status");
@@ -245,7 +246,7 @@
     }
 
     void deleteChecked() {
-      final HashSet<Integer> sequenceNumbers = new HashSet<Integer>();
+      final HashSet<Integer> sequenceNumbers = new HashSet<>();
       for (int row = 1; row < getRowCount(); row++) {
         SshKeyInfo k = getRowItem(row);
         if (k != null && ((CheckBox) getWidget(row, 1)).getValue()) {
@@ -259,6 +260,7 @@
           new RestApi("config").id("server")
               .view(Plugin.get().getPluginName(), "serviceusers").id(serviceUser)
               .view("sshkeys").id(seq).delete(new AsyncCallback<NoContent>() {
+                @Override
                 public void onSuccess(NoContent result) {
                   for (int row = 1; row < getRowCount();) {
                     SshKeyInfo k = getRowItem(row);
diff --git a/src/main/java/com/googlesource/gerrit/plugins/serviceuser/client/StringListPanel.java b/src/main/java/com/googlesource/gerrit/plugins/serviceuser/client/StringListPanel.java
index 2a2f970..a809a6d 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/serviceuser/client/StringListPanel.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/serviceuser/client/StringListPanel.java
@@ -140,7 +140,7 @@
     }
 
     List<String> getValues() {
-      List<String> values = new ArrayList<String>();
+      List<String> values = new ArrayList<>();
       for (int row = 1; row < getRowCount(); row++) {
         values.add(getText(row, 1));
       }
diff --git a/src/main/resources/Documentation/build.md b/src/main/resources/Documentation/build.md
index f246813..2fe95a3 100644
--- a/src/main/resources/Documentation/build.md
+++ b/src/main/resources/Documentation/build.md
@@ -3,6 +3,47 @@
 
 This plugin is built with Buck.
 
+Two build modes are supported: Standalone and in Gerrit tree. Standalone
+build mode is recommended, as this mode doesn't require local Gerrit
+tree to exist.
+
+Build standalone
+----------------
+
+Clone bucklets library:
+
+```
+  git clone https://gerrit.googlesource.com/bucklets
+
+```
+and link it to serviceuser directory:
+
+```
+  cd serviceuser && ln -s ../bucklets .
+```
+
+Add link to the .buckversion file:
+
+```
+  cd serviceuser && ln -s bucklets/buckversion .buckversion
+```
+
+To build the plugin, issue the following command:
+
+
+```
+  buck build plugin
+```
+
+The output is created in
+
+```
+  buck-out/gen/serviceuser/serviceuser.jar
+```
+
+Build in Gerrit tree
+--------------------
+
 Clone or link this plugin to the plugins directory of Gerrit's source
 tree, and issue the command: