[Yanel-commits] rev 32785 -
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 3 11:03:29 CET 2008
Author: michi
Date: 2008-03-03 11:03:28 +0100 (Mon, 03 Mar 2008)
New Revision: 32785
Added:
public/yanel/contributions/ajax-components/src/access-policy-editor/java/org/wyona/security/gwt/accesspolicyeditor/client/Group.java
Modified:
public/yanel/contributions/ajax-components/src/access-policy-editor/java/org/wyona/security/gwt/accesspolicyeditor/client/AccessPolicyEditor.java
public/yanel/contributions/ajax-components/src/access-policy-editor/java/org/wyona/security/gwt/accesspolicyeditor/client/AsynchronousPolicySetter.java
public/yanel/contributions/ajax-components/src/access-policy-editor/java/org/wyona/security/gwt/accesspolicyeditor/client/PolicyListBoxWidget.java
Log:
groups added for saving as well
Modified: public/yanel/contributions/ajax-components/src/access-policy-editor/java/org/wyona/security/gwt/accesspolicyeditor/client/AccessPolicyEditor.java
===================================================================
--- public/yanel/contributions/ajax-components/src/access-policy-editor/java/org/wyona/security/gwt/accesspolicyeditor/client/AccessPolicyEditor.java 2008-03-03 09:55:39 UTC (rev 32784)
+++ public/yanel/contributions/ajax-components/src/access-policy-editor/java/org/wyona/security/gwt/accesspolicyeditor/client/AccessPolicyEditor.java 2008-03-03 10:03:28 UTC (rev 32785)
@@ -93,7 +93,7 @@
public void onClick(Widget sender) {
final AsynchronousPolicySetter aps = new AsynchronousPolicySetter(savePolicyUrl);
try {
- com.google.gwt.http.client.Request request = aps.sendRequest(policyLBW.getUsers());
+ com.google.gwt.http.client.Request request = aps.sendRequest(policyLBW.getUsers(), policyLBW.getGroups());
} catch (Exception e) {
Window.alert("Exception: " + e.getMessage());
}
Modified: public/yanel/contributions/ajax-components/src/access-policy-editor/java/org/wyona/security/gwt/accesspolicyeditor/client/AsynchronousPolicySetter.java
===================================================================
--- public/yanel/contributions/ajax-components/src/access-policy-editor/java/org/wyona/security/gwt/accesspolicyeditor/client/AsynchronousPolicySetter.java 2008-03-03 09:55:39 UTC (rev 32784)
+++ public/yanel/contributions/ajax-components/src/access-policy-editor/java/org/wyona/security/gwt/accesspolicyeditor/client/AsynchronousPolicySetter.java 2008-03-03 10:03:28 UTC (rev 32785)
@@ -41,7 +41,7 @@
/**
*
*/
- public Request sendRequest(User[] users) throws RequestException {
+ public Request sendRequest(User[] users, Group[] groups) throws RequestException {
StringBuffer data = new StringBuffer("<?xml version=\"1.0\"?>");
data.append("<policy>");
if (users != null) {
@@ -56,6 +56,18 @@
data.append("</user>");
}
}
+ if (groups != null) {
+ for (int i = 0; i < groups.length; i++) {
+ data.append("<group id=\"" + groups[i].getId() + "\">");
+ String[] rights = groups[i].getRights();
+ if (rights != null) {
+ for (int k = 0; k < rights.length; k++) {
+ data.append("<right id=\"" + rights[k] + "\">" + rights[k] + "</right>");
+ }
+ }
+ data.append("</group>");
+ }
+ }
data.append("</policy>");
return requestBuilder.sendRequest(data.toString(), this);
}
Added: public/yanel/contributions/ajax-components/src/access-policy-editor/java/org/wyona/security/gwt/accesspolicyeditor/client/Group.java
===================================================================
--- public/yanel/contributions/ajax-components/src/access-policy-editor/java/org/wyona/security/gwt/accesspolicyeditor/client/Group.java (rev 0)
+++ public/yanel/contributions/ajax-components/src/access-policy-editor/java/org/wyona/security/gwt/accesspolicyeditor/client/Group.java 2008-03-03 10:03:28 UTC (rev 32785)
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2008 Wyona
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.wyona.security.gwt.accesspolicyeditor.client;
+
+/**
+ *
+ */
+public class Group {
+
+ private String id;
+ private String[] rights;
+
+ /**
+ *
+ */
+ public Group(String id, String[] rights) {
+ this.id = id;
+ this.rights = rights;
+ }
+
+ /**
+ *
+ */
+ public String getId() {
+ return id;
+ }
+
+ /**
+ *
+ */
+ public String[] getRights() {
+ return rights;
+ }
+}
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-03 09:55:39 UTC (rev 32784)
+++ public/yanel/contributions/ajax-components/src/access-policy-editor/java/org/wyona/security/gwt/accesspolicyeditor/client/PolicyListBoxWidget.java 2008-03-03 10:03:28 UTC (rev 32785)
@@ -255,15 +255,41 @@
*
*/
public User[] getUsers() {
- User[] users = new User[lb.getItemCount()];
- for (int i = 0; i < users.length; i++) {
+ Vector users = new Vector();
+ for (int i = 0; i < lb.getItemCount(); i++) {
String itemText = lb.getItemText(i);
String[] rights = getRights(itemText);
String id = getIdentityWithoutRights(itemText);
if (id.startsWith("u:")) {
- users[i] = new User(id.substring(2).trim(), rights);
+ users.add(new User(id.substring(2).trim(), rights));
}
}
- return users;
+
+ User[] u = new User[users.size()];
+ for (int i = 0; i < u.length; i++) {
+ u[i] = (User) users.elementAt(i);
+ }
+ return u;
}
+
+ /**
+ *
+ */
+ public Group[] getGroups() {
+ Vector groups = new Vector();
+ for (int i = 0; i < lb.getItemCount(); i++) {
+ String itemText = lb.getItemText(i);
+ String[] rights = getRights(itemText);
+ String id = getIdentityWithoutRights(itemText);
+ if (id.startsWith("g:")) {
+ groups.add(new Group(id.substring(2).trim(), rights));
+ }
+ }
+
+ Group[] g = new Group[groups.size()];
+ for (int i = 0; i < g.length; i++) {
+ g[i] = (Group) groups.elementAt(i);
+ }
+ return g;
+ }
}
More information about the Yanel-commits
mailing list