[Yanel-commits] rev 33170 - public/yanel/contributions/ajax-components/src/access-policy-editor/java/org/wyona/security/gwt/accesspolicyeditor/client

michi at wyona.com michi at wyona.com
Mon Mar 10 14:40:45 CET 2008


Author: michi
Date: 2008-03-10 14:40:44 +0100 (Mon, 10 Mar 2008)
New Revision: 33170

Modified:
   public/yanel/contributions/ajax-components/src/access-policy-editor/java/org/wyona/security/gwt/accesspolicyeditor/client/PolicyListBoxWidget.java
Log:
add rights dynamically

Modified: public/yanel/contributions/ajax-components/src/access-policy-editor/java/org/wyona/security/gwt/accesspolicyeditor/client/PolicyListBoxWidget.java
===================================================================
--- public/yanel/contributions/ajax-components/src/access-policy-editor/java/org/wyona/security/gwt/accesspolicyeditor/client/PolicyListBoxWidget.java	2008-03-10 13:28:32 UTC (rev 33169)
+++ public/yanel/contributions/ajax-components/src/access-policy-editor/java/org/wyona/security/gwt/accesspolicyeditor/client/PolicyListBoxWidget.java	2008-03-10 13:40:44 UTC (rev 33170)
@@ -83,14 +83,74 @@
         if (users != null || groups != null) {
             if (users != null) {
                 for (int i = 0; i < users.length; i++) {
-                    String label = "u: ("+READ_RIGHT+","+WRITE_RIGHT+") " + users[i].getId();
+                    String label = "u: (";
+
+                    String[] rights = users[i].getRights();
+
+                    boolean readExists = false;
+                    for (int k = 0; k < rights.length; k++) {
+                        if (rights[k].equals(READ_RIGHT)) {
+                            readExists = true;
+                            break;
+                        }
+                    }
+                    if (readExists) {
+                        label = label + READ_RIGHT;
+                    } else {
+                        label = label + "-";
+                    }
+                    label = label + ",";
+                    boolean writeExists = false;
+                    for (int k = 0; k < rights.length; k++) {
+                        if (rights[k].equals(WRITE_RIGHT)) {
+                            writeExists = true;
+                            break;
+                        }
+                    }
+                    if (writeExists) {
+                        label = label + WRITE_RIGHT;
+                    } else {
+                        label = label + "-";
+                    }
+
+                    label = label +") " + users[i].getId();
+
                     String value = "u: " + users[i].getId();
                     lb.addItem(label, value);
                 }
             }
             if (groups != null) {
                 for (int i = 0; i < groups.length; i++) {
-                    String label = "g: ("+READ_RIGHT+","+WRITE_RIGHT+") " + groups[i].getId();
+                    String label = "g: (";
+                    String[] rights = groups[i].getRights();
+
+                    boolean readExists = false;
+                    for (int k = 0; k < rights.length; k++) {
+                        if (rights[k].equals(READ_RIGHT)) {
+                            readExists = true;
+                            break;
+                        }
+                    }
+                    if (readExists) {
+                        label = label + READ_RIGHT;
+                    } else {
+                        label = label + "-";
+                    }
+                    label = label + ",";
+                    boolean writeExists = false;
+                    for (int k = 0; k < rights.length; k++) {
+                        if (rights[k].equals(WRITE_RIGHT)) {
+                            writeExists = true;
+                            break;
+                        }
+                    }
+                    if (writeExists) {
+                        label = label + WRITE_RIGHT;
+                    } else {
+                        label = label + "-";
+                    }
+
+                    label = label + ") " + groups[i].getId();
                     String value = "g: " + groups[i].getId();
                     lb.addItem(label, value);
                 }



More information about the Yanel-commits mailing list