Don't hyperlink non-internal groups

When an external group (such as LDAP) is used in a permission rule,
don't attempt to link to the group in the internal account system UI.
The group won't load successfully. Instead just display the name and
put the UUID into a tooltip to show the full DN.

Change-Id: I8fbb67a36da5d5fcb69b4f90bfedbc2638896886
This commit is contained in:
Shawn O. Pearce
2012-06-05 09:01:42 -07:00
parent 7e7e5edf8b
commit 6fe3e99bc9
3 changed files with 19 additions and 8 deletions

View File

@@ -25,6 +25,7 @@ import com.google.gerrit.common.data.GroupReference;
import com.google.gerrit.common.data.Permission;
import com.google.gerrit.common.data.PermissionRange;
import com.google.gerrit.common.data.PermissionRule;
import com.google.gerrit.reviewdb.client.AccountGroup;
import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.DivElement;
import com.google.gwt.dom.client.SpanElement;
@@ -178,16 +179,21 @@ public class PermissionRuleEditor extends Composite implements
@Override
public void setValue(PermissionRule value) {
GroupReference ref = value.getGroup();
if (ref.getUUID() != null) {
boolean link;
if (ref.getUUID() != null && AccountGroup.isInternalGroup(ref.getUUID())) {
groupNameLink.setText(ref.getName());
groupNameLink.setTargetHistoryToken(Dispatcher.toGroup(ref.getUUID()));
link = true;
} else {
groupNameSpan.setInnerText(ref.getName());
groupNameSpan.setTitle(ref.getUUID() != null ? ref.getUUID().get() : "");
link = false;
}
groupNameLink.setText(ref.getName());
groupNameSpan.setInnerText(ref.getName());
deletedGroupName.setInnerText(ref.getName());
groupNameLink.setVisible(ref.getUUID() != null);
UIObject.setVisible(groupNameSpan, ref.getUUID() == null);
groupNameLink.setVisible(link);
UIObject.setVisible(groupNameSpan, !link);
}
@Override

View File

@@ -79,6 +79,12 @@ public final class AccountGroup {
}
}
/** @return true if the UUID is for a group managed within Gerrit. */
public static boolean isInternalGroup(AccountGroup.UUID uuid) {
return uuid.get().startsWith("global:")
|| uuid.get().matches("[0-9a-f]{40}");
}
/** Synthetic key to link to within the database */
public static class Id extends IntKey<com.google.gwtorm.client.Key<?>> {
private static final long serialVersionUID = 1L;

View File

@@ -57,8 +57,7 @@ public class InternalGroupBackend implements GroupBackend {
@Override
public boolean handles(AccountGroup.UUID uuid) {
return uuid.get().startsWith("global:")
|| uuid.get().matches("[0-9a-f]{40}");
return AccountGroup.isInternalGroup(uuid);
}
@Override