Merge branch 'stable-3.1' * stable-3.1: Remove unused exceptions Revert "Check if full name and email edit are allowed in realm" PutOwner: Adapt to latest master API for AccountGroup UUID. Switch to the snapshot API so the latter fix compiles and runs. Change-Id: Iae0217e472fa05f0fb7902c18f9e7232d9219847
diff --git a/WORKSPACE b/WORKSPACE index 8d03fe2..b2e1c99 100644 --- a/WORKSPACE +++ b/WORKSPACE
@@ -8,19 +8,19 @@ ) # Snapshot Plugin API -#load( -# "@com_googlesource_gerrit_bazlets//:gerrit_api_maven_local.bzl", -# "gerrit_api_maven_local", -#) - -# Load snapshot Plugin API -#gerrit_api_maven_local() - -# Release Plugin API load( - "@com_googlesource_gerrit_bazlets//:gerrit_api.bzl", - "gerrit_api", + "@com_googlesource_gerrit_bazlets//:gerrit_api_maven_local.bzl", + "gerrit_api_maven_local", ) +# Load snapshot Plugin API +gerrit_api_maven_local() + +# Release Plugin API +#load( +# "@com_googlesource_gerrit_bazlets//:gerrit_api.bzl", +# "gerrit_api", +#) + # Load release Plugin API -gerrit_api() +#gerrit_api()
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 eb10974..93fc84c 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/serviceuser/CreateServiceUserNotes.java +++ b/src/main/java/com/googlesource/gerrit/plugins/serviceuser/CreateServiceUserNotes.java
@@ -25,12 +25,10 @@ import com.google.gerrit.server.GerritPersonIdent; import com.google.gerrit.server.config.AnonymousCowardName; import com.google.gerrit.server.git.NotesBranchUtil; -import com.google.gerrit.server.permissions.PermissionBackendException; import com.google.inject.Inject; import com.google.inject.assistedinject.Assisted; import com.googlesource.gerrit.plugins.serviceuser.GetServiceUser.ServiceUserInfo; import java.io.IOException; -import org.eclipse.jgit.errors.ConfigInvalidException; import org.eclipse.jgit.lib.Constants; import org.eclipse.jgit.lib.ObjectId; import org.eclipse.jgit.lib.ObjectInserter; @@ -81,7 +79,7 @@ } void createNotes(String branch, ObjectId oldObjectId, ObjectId newObjectId) - throws IOException, ConfigInvalidException, PermissionBackendException, RestApiException { + throws IOException, RestApiException { if (ObjectId.zeroId().equals(newObjectId)) { return; } @@ -153,13 +151,13 @@ } private ObjectId createNoteContent(String branch, ServiceUserInfo serviceUser) - throws IOException, PermissionBackendException, RestApiException, RuntimeException { + throws IOException, RestApiException, RuntimeException { return getInserter() .insert(Constants.OBJ_BLOB, createServiceUserNote(branch, serviceUser).getBytes(UTF_8)); } private String createServiceUserNote(String branch, ServiceUserInfo serviceUser) - throws PermissionBackendException, RestApiException, RuntimeException { + throws RestApiException, RuntimeException { HeaderFormatter fmt = new HeaderFormatter(gerritServerIdent.getTimeZone(), anonymousCowardName); fmt.appendDate(); fmt.append("Project", project.get());
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 8453e51..fd8bbbf 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/serviceuser/PutOwner.java +++ b/src/main/java/com/googlesource/gerrit/plugins/serviceuser/PutOwner.java
@@ -111,7 +111,7 @@ } else { group = groups.parse(TopLevelResource.INSTANCE, IdString.fromDecoded(input.group)).getGroup(); UUID groupUUID = group.getGroupUUID(); - if (!AccountGroup.isInternalGroup(groupUUID)) { + if (!AccountGroup.uuid(groupUUID.get()).isInternalGroup()) { throw new MethodNotAllowedException("Group with UUID '" + groupUUID + "' is external"); } db.setString(USER, rsrc.getUser().getUserName().get(), KEY_OWNER, groupUUID.get());
diff --git a/src/main/java/com/googlesource/gerrit/plugins/serviceuser/RefUpdateListener.java b/src/main/java/com/googlesource/gerrit/plugins/serviceuser/RefUpdateListener.java index 887f1e3..31d1a56 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/serviceuser/RefUpdateListener.java +++ b/src/main/java/com/googlesource/gerrit/plugins/serviceuser/RefUpdateListener.java
@@ -23,11 +23,9 @@ import com.google.gerrit.server.git.GitRepositoryManager; import com.google.gerrit.server.git.ProjectRunnable; import com.google.gerrit.server.git.WorkQueue; -import com.google.gerrit.server.permissions.PermissionBackendException; import com.google.inject.Inject; import com.google.inject.Singleton; import java.io.IOException; -import org.eclipse.jgit.errors.ConfigInvalidException; import org.eclipse.jgit.lib.ObjectId; import org.eclipse.jgit.lib.Repository; import org.slf4j.Logger; @@ -107,10 +105,7 @@ ObjectId.fromString(e.getOldObjectId()), ObjectId.fromString(e.getNewObjectId())); crn.commitNotes(); - } catch (IOException - | ConfigInvalidException - | PermissionBackendException - | RestApiException x) { + } catch (IOException | RestApiException x) { log.error(x.getMessage(), x); } }
diff --git a/src/main/resources/static/gr-serviceuser-detail.html b/src/main/resources/static/gr-serviceuser-detail.html index e515ee6..41e4e8d 100644 --- a/src/main/resources/static/gr-serviceuser-detail.html +++ b/src/main/resources/static/gr-serviceuser-detail.html
@@ -101,7 +101,6 @@ on-keyup="_computePrefsChanged"> </iron-input> </span> - <span class="value" hidden$="[[_allowFullName]]">[[_serviceUser.name]]</span> </section> <section> <span class="title">Email Address</span>
diff --git a/src/main/resources/static/gr-serviceuser-detail.js b/src/main/resources/static/gr-serviceuser-detail.js index 53ec980..95aded2 100644 --- a/src/main/resources/static/gr-serviceuser-detail.js +++ b/src/main/resources/static/gr-serviceuser-detail.js
@@ -25,7 +25,6 @@ _restApi: Object, _serviceUserId: String, _serviceUser: Object, - _serverConfig: Object, _loading: { type: Boolean, value: true, @@ -50,10 +49,6 @@ type: Boolean, value: false, }, - _allowFullName: { - type: Boolean, - value: false, - }, _allowOwner: { type: Boolean, value: false, @@ -80,10 +75,8 @@ ], attached() { - this._getPermissions().then(() => { - this._extractUserId(); - this._loadServiceUser(); - }); + this._extractUserId(); + this._loadServiceUser(); }, _loadServiceUser() { @@ -93,7 +86,6 @@ promises.push(this._getPluginConfig()); promises.push(this._getServiceUser()); - promises.push(this._getServerConfig()); Promise.all(promises).then(() => { this.$.sshEditor.loadData(this._restApi, this._serviceUser); @@ -104,11 +96,6 @@ this._loading = false; this._newFullName = this._serviceUser.name; this._newEmail = this._serviceUser.email; - this._allowFullName = this._serverConfig.auth.editable_account_fields - .includes('FULL_NAME'); - this._allowEmail = this._allowEmail && - this._serverConfig.auth.editable_account_fields - .includes('REGISTER_NEW_EMAIL'); }); }, @@ -128,25 +115,17 @@ }, _getPluginConfig() { - return this.plugin.restApi('/config/server/serviceuser~config/').get('') - .then(config => { - if (!config) { - return; - } - this._allowEmail = config.allow_email || this._isAdmin; - this._allowOwner = config.allow_owner || this._isAdmin; - this._allowHttpPassword = config.allow_http_password - || this._isAdmin; - }); - }, - - _getServerConfig() { - return this.plugin.restApi().getConfig().then(cfg => { - if (!cfg) { - return; - } - - this._serverConfig = cfg; + return Promise.resolve(this._getPermissions()).then(() => { + this.plugin.restApi('/config/server/serviceuser~config/').get('') + .then(config => { + if (!config) { + return; + } + this._allowEmail = config.allow_email || this._isAdmin; + this._allowOwner = config.allow_owner || this._isAdmin; + this._allowHttpPassword = config.allow_http_password + || this._isAdmin; + }); }); },