]> WPIA git - gigi.git/blobdiff - src/org/cacert/gigi/output/GroupSelector.java
upd: remove linear search in GroupSelector
[gigi.git] / src / org / cacert / gigi / output / GroupSelector.java
index 4452a09d1038d05475d73bbc2c2e957fc83876d8..49db7050f94fe3e80f580cfbe2ed48a521d2f9bd 100644 (file)
@@ -26,13 +26,12 @@ public class GroupSelector implements Outputable {
 
     public void update(HttpServletRequest r) throws GigiApiException {
         String vS = r.getParameter(name);
-        value = null;
-        for (Group g : Group.values()) {
-            if (g.getDatabaseName().equals(vS) && mayManage(g)) {
-                value = g;
-            }
+        if (vS == null) {
+            throw new GigiApiException("No value for group.");
         }
-        if (value == null) {
+        try {
+            value = Group.getByString(vS);
+        } catch (IllegalArgumentException e) {
             throw new GigiApiException("Invalid value for group.");
         }
     }