lenya-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From andr...@apache.org
Subject svn commit: r178145 - in /lenya/trunk/src: java/org/apache/lenya/cms/ac/usecases/AccessControl.java webapp/lenya/usecases/tab/ac/ac.jx
Date Tue, 24 May 2005 09:42:35 GMT
Author: andreas
Date: Tue May 24 02:42:34 2005
New Revision: 178145

URL: http://svn.apache.org/viewcvs?rev=178145&view=rev
Log:
fixed credential adding+deletion on AC tab usecases

Modified:
    lenya/trunk/src/java/org/apache/lenya/cms/ac/usecases/AccessControl.java
    lenya/trunk/src/webapp/lenya/usecases/tab/ac/ac.jx

Modified: lenya/trunk/src/java/org/apache/lenya/cms/ac/usecases/AccessControl.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/ac/usecases/AccessControl.java?rev=178145&r1=178144&r2=178145&view=diff
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/ac/usecases/AccessControl.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/ac/usecases/AccessControl.java Tue May 24 02:42:34
2005
@@ -57,7 +57,11 @@
     protected static final String ADD = "add";
     protected static final String DELETE = "delete";
 
-    private static String[] types = { "user", "group", "iprange", "role" };
+    protected static final String USER = "user";
+    protected static final String GROUP = "group";
+    protected static final String IPRANGE = "ipRange";
+    protected static final String ROLE = "role";
+    private static String[] types = { USER, GROUP, IPRANGE };
     private static String[] operations = { ADD, DELETE };
 
     protected static final String SSL = "ssl";
@@ -127,44 +131,10 @@
             Arrays.sort(roleIds);
             setParameter("roles", roleIds);
             setParameter("visitorRole", visitorRole);
-            
+
             setParameter(URL_CREDENTIALS, getURICredentials());
             setParameter(PARENT_CREDENTIALS, getParentCredentials());
 
-            for (int i = 0; i < types.length; i++) {
-                Item[] _items = null;
-
-                if (types[i].equals("user")) {
-                    _items = getUserManager().getUsers();
-                } else if (types[i].equals("group")) {
-                    _items = getGroupManager().getGroups();
-                } else if (types[i].equals("iprange")) {
-                    _items = getIpRangeManager().getIPRanges();
-                } else if (types[i].equals("role")) {
-                    _items = getRoleManager().getRoles();
-                }
-                for (int j = 0; j < operations.length; j++) {
-                    if (getParameterAsString(operations[j] + "_credential_" + types[i]) !=
null) {
-                        String roleId = getParameterAsString("role_id");
-
-                        String accreditableId = getParameterAsString("accreditable_id");
-                        Item item = null;
-                        for (int k = 0; k < _items.length; k++) {
-                            if (accreditableId.equals(_items[k].getId())) {
-                                item = _items[k];
-                            }
-                        }
-
-                        Role role = getRoleManager().getRole(roleId);
-
-                        if (role == null) {
-                            addErrorMessage("role_no_such_role", new String[] { roleId });
-                        }
-
-                        manipulateCredential(item, role, operations[j]);
-                    }
-                }
-            }
         } catch (final Exception e) {
             addErrorMessage("Could not read a value.");
             getLogger().error("Could not read value for AccessControl usecase. ", e);
@@ -209,6 +179,37 @@
                 deleteParameter("change_ssl");
                 deleteParameter("ssl");
             }
+
+            for (int i = 0; i < types.length; i++) {
+                for (int j = 0; j < operations.length; j++) {
+                    String paramName = operations[j] + "Credential_" + types[i];
+                    if (getParameterAsString(paramName) != null) {
+                        String roleId = getParameterAsString(ROLE);
+
+                        String id = getParameterAsString(types[i]);
+                        Item item = null;
+                        if (types[i].equals(USER)) {
+                            item = getUserManager().getUser(id);
+                        } else if (types[i].equals(GROUP)) {
+                            item = getGroupManager().getGroup(id);
+                        } else if (types[i].equals(IPRANGE)) {
+                            item = getIpRangeManager().getIPRange(id);
+                        }
+                        if (item == null) {
+                            addErrorMessage("no_such_accreditable", new String[] { types[i],
id });
+                        } else {
+                            Role role = getRoleManager().getRole(roleId);
+                            if (role == null) {
+                                addErrorMessage("role_no_such_role", new String[] { roleId
});
+                            }
+                            manipulateCredential(item, role, operations[j]);
+                            setParameter(URL_CREDENTIALS, getURICredentials());
+                        }
+                        deleteParameter(paramName);
+                    }
+                }
+            }
+
         } catch (Exception e) {
             throw new UsecaseException(e);
         }
@@ -404,11 +405,11 @@
 
         return policies;
     }
-    
+
     protected String getPolicyURL() {
         String infoUrl = getSourceURL();
         URLInformation info = new URLInformation(infoUrl);
-        
+
         String area = getParameterAsString("acArea");
         String url = "/" + info.getPublicationId() + "/" + area + info.getDocumentUrl();
         return url;

Modified: lenya/trunk/src/webapp/lenya/usecases/tab/ac/ac.jx
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/webapp/lenya/usecases/tab/ac/ac.jx?rev=178145&r1=178144&r2=178145&view=diff
==============================================================================
--- lenya/trunk/src/webapp/lenya/usecases/tab/ac/ac.jx (original)
+++ lenya/trunk/src/webapp/lenya/usecases/tab/ac/ac.jx Tue May 24 02:42:34 2005
@@ -25,141 +25,157 @@
     <jx:import uri="tab/sitetree.jx"/>
     <jx:import uri="tab/tabs.jx"/>
     
-    <jx:set var="area" value="${usecase.getParameter('document').getArea()}"/>
+    <jx:set var="area" value="${usecase.getParameter('acArea')}"/>
     <div id="contentblock1" class="lenya-tab-sitetree">
-      <table class="lenya-table-noborder">
+      <table class="lenya-table">
         <tr>
-          <td>
+          <td colspan="4">
+            <jx:import uri="templates/messages.jx"/>
+          </td>
+        </tr>
+        <tr>
+          <th colspan="4">
             <jx:import uri="tab/ac/ssl-form.jx"/>
-           </td>
+          </th>
         </tr>
+        <tr><td colspan="4">&#160;</td></tr>
         <tr>
-          <td>
-            <table class="lenya-table">
-              <tr>
-                <th colspan="2">
-                  <i18n:text>Access Object</i18n:text>
-                </th>
-                <th>
-                  <jx:if test="${area.equals('authoring')}">
-                    <i18n:text>Role</i18n:text>
-                  </jx:if>&#160;
-                </th>
-                <th/>
-              </tr>
-              <tr>
-                
-                <form method="get">
-                  <input type="hidden" name="lenya.usecase" value="${usecase.getName()}"/>
-                  <input type="hidden" name="lenya.continuation" value="${continuation.id}"/>
-                  <td><i18n:text>user</i18n:text></td>
-                  <td>
-                    <select name="user" class="lenya-form-element-narrow">
-                      <jx:forEach var="user" items="${usecase.getParameter('users')}">
-                        <option value="${user}"><jx:out value="${user}"/></option>
-                      </jx:forEach>
-                    </select>
-                  </td>
-                  <td>
-                    <select name="userRole" class="lenya-form-element-narrow">
-                      <jx:forEach var="role" items="${usecase.getParameter('roles')}">
-                        <option value="${role}"><jx:out value="${role}"/></option>
-                      </jx:forEach>
-                    </select>
-                  </td>
-                  <td>
-                    <input i18n:attr="value" type="submit" name="addCredential_user" value="Add"/>
-                  </td>
-                </form>
-                          
-              </tr>
-              <tr>
-                <form method="get">
-                  <input type="hidden" name="lenya.usecase" value="${usecase.getName()}"/>
-                  <input type="hidden" name="lenya.continuation" value="${continuation.id}"/>
-                  <td><i18n:text>group</i18n:text></td>
-                  <td>
-                    <select name="group" class="lenya-form-element-narrow">
-                      <jx:forEach var="group" items="${usecase.getParameter('groups')}">
-                        <option value="${group}"><jx:out value="${group}"/></option>
-                      </jx:forEach>
-                    </select>
-                  </td>
-                  <td>
-                    <select name="groupRole" class="lenya-form-element-narrow">
-                      <jx:forEach var="role" items="${usecase.getParameter('roles')}">
-                        <option value="${role}"><jx:out value="${role}"/></option>
-                      </jx:forEach>
-                    </select>
-                  </td>
-                  <td>
-                    <input i18n:attr="value" type="submit" name="addCredential_group"
value="Add"/>
-                  </td>
-                </form>
-              </tr>
-              <jx:if test="${area.equals('live')}">
-                <tr>
-                  <form method="get">
-                    <input type="hidden" name="lenya.usecase" value="${usecase.getName()}"/>
-                    <input type="hidden" name="lenya.continuation" value="${continuation.id}"/>
-                    <td><i18n:text>IP Range</i18n:text></td>
-                    <td>
-                      <select name="ipRange" class="lenya-form-element-narrow">
-                        <jx:forEach var="ipRange" items="${usecase.getParameter('ipRanges')}">
-                          <option value="${ipRange}"><jx:out value="${ipRange}"/></option>
-                        </jx:forEach>
-                      </select>
-                    </td>
-                    <td>
-                      <select name="ipRangeRole" class="lenya-form-element-narrow">
-                        <jx:forEach var="role" items="${usecase.getParameter('roles')}">
-                          <option value="${role}"><jx:out value="${role}"/></option>
-                        </jx:forEach>
-                      </select>
-                    </td>
-                    <td>
-                      <input i18n:attr="value" type="submit" name="addCredential_ipRange"
value="Add"/>
-                    </td>
-                  </form>
-                </tr>
-              </jx:if>
-              
-              <jx:forEach var="credential" items="${usecase.getParameter('urlCredentials')}">
-                <form>
-                  <tr>
-                    <td>
-                      <i18n:text><jx:out value="${credential.getType()}"/></i18n:text>
-                    </td>
-                    <td>
-                      <jx:out value="${credential.getAccreditableId()}"/>
-                    </td>
-                    <td>
-                      <jx:out value="${credential.getRoleId()}"/>
-                    </td>
-                    <td>
-                      <input type="submit" name="deleteCredential" i18n:attr="value" value="Delete"/>
-                    </td>
-                  </tr>
-                </form>
-              </jx:forEach>
-              
-              <jx:forEach var="credential" items="${usecase.getParameter('parentCredentials')}">
-                <tr>
-                  <td>
-                    <i18n:text><jx:out value="${credential.getType()}"/></i18n:text>
-                  </td>
-                  <td>
-                    <jx:out value="${credential.getAccreditableId()}"/>
-                  </td>
-                  <td colspan="2">
-                    <jx:out value="${credential.getRoleId()}"/>
-                  </td>
-                </tr>
-              </jx:forEach>
-              
-            </table>
-          </td>
+          <th colspan="2">
+            <i18n:text>Access Object</i18n:text>
+          </th>
+          <th>
+            <jx:if test="${area.equals('authoring')}">
+              <i18n:text>Role</i18n:text>
+            </jx:if>&#160;
+          </th>
+          <th/>
+        </tr>
+        <tr>
+          
+          <form method="get">
+            <input type="hidden" name="lenya.usecase" value="${usecase.getName()}"/>
+            <input type="hidden" name="lenya.continuation" value="${continuation.id}"/>
+            <td><i18n:text>user</i18n:text></td>
+            <td>
+              <select name="user" class="lenya-form-element-narrow">
+                <jx:forEach var="user" items="${usecase.getParameter('users')}">
+                  <option value="${user}"><jx:out value="${user}"/></option>
+                </jx:forEach>
+              </select>
+            </td>
+            <td>
+              <select name="role" class="lenya-form-element-narrow">
+                <jx:forEach var="role" items="${usecase.getParameter('roles')}">
+                  <option value="${role}"><jx:out value="${role}"/></option>
+                </jx:forEach>
+              </select>
+            </td>
+            <td>
+              <input i18n:attr="value" type="submit" name="addCredential_user" value="Add"/>
+            </td>
+          </form>
+                    
+        </tr>
+        <tr>
+          <form method="get">
+            <input type="hidden" name="lenya.usecase" value="${usecase.getName()}"/>
+            <input type="hidden" name="lenya.continuation" value="${continuation.id}"/>
+            <td><i18n:text>group</i18n:text></td>
+            <td>
+              <select name="group" class="lenya-form-element-narrow">
+                <jx:forEach var="group" items="${usecase.getParameter('groups')}">
+                  <option value="${group}"><jx:out value="${group}"/></option>
+                </jx:forEach>
+              </select>
+            </td>
+            <td>
+              <select name="role" class="lenya-form-element-narrow">
+                <jx:forEach var="role" items="${usecase.getParameter('roles')}">
+                  <option value="${role}"><jx:out value="${role}"/></option>
+                </jx:forEach>
+              </select>
+            </td>
+            <td>
+              <input i18n:attr="value" type="submit" name="addCredential_group" value="Add"/>
+            </td>
+          </form>
+        </tr>
+        <jx:if test="${area.equals('live')}">
+          <tr>
+            <form method="get">
+              <input type="hidden" name="lenya.usecase" value="${usecase.getName()}"/>
+              <input type="hidden" name="lenya.continuation" value="${continuation.id}"/>
+              <td><i18n:text>IP Range</i18n:text></td>
+              <td>
+                <select name="ipRange" class="lenya-form-element-narrow">
+                  <jx:forEach var="ipRange" items="${usecase.getParameter('ipRanges')}">
+                    <option value="${ipRange}"><jx:out value="${ipRange}"/></option>
+                  </jx:forEach>
+                </select>
+              </td>
+              <td>
+                <select name="role" class="lenya-form-element-narrow">
+                  <jx:forEach var="role" items="${usecase.getParameter('roles')}">
+                    <option value="${role}"><jx:out value="${role}"/></option>
+                  </jx:forEach>
+                </select>
+              </td>
+              <td>
+                <input i18n:attr="value" type="submit" name="addCredential_ipRange" value="Add"/>
+              </td>
+            </form>
+          </tr>
+        </jx:if>
+        
+        <tr><td colspan="4">&#160;</td></tr>
+        <tr>
+          <th colspan="4">
+            <i18n:text>URL Rights</i18n:text>
+          </th>
+        </tr>
+        <jx:forEach var="credential" items="${usecase.getParameter('urlCredentials')}">
+          <form method="get">
+            <input type="hidden" name="lenya.usecase" value="${usecase.getName()}"/>
+            <input type="hidden" name="lenya.continuation" value="${continuation.id}"/>
+            <tr>
+              <td>
+                <i18n:text><jx:out value="${credential.getType()}"/></i18n:text>
+              </td>
+              <td>
+                <input type="hidden" name="${credential.getType()}" value="${credential.getAccreditableId()}"/>
+                <jx:out value="${credential.getAccreditableId()}"/>
+              </td>
+              <td>
+                <input type="hidden" name="role" value="${credential.getRoleId()}"/>
+                <jx:out value="${credential.getRoleId()}"/>
+              </td>
+              <td>
+                <input type="submit" name="deleteCredential_${credential.getType()}" i18n:attr="value"
value="Delete"/>
+              </td>
+            </tr>
+          </form>
+        </jx:forEach>
+        
+        <tr><td colspan="4">&#160;</td></tr>
+        <tr>
+          <th colspan="4">
+            <i18n:text>Inherited Rights</i18n:text>
+          </th>
         </tr>
+        <jx:forEach var="credential" items="${usecase.getParameter('parentCredentials')}">
+          <tr>
+            <td>
+              <i18n:text><jx:out value="${credential.getType()}"/></i18n:text>
+            </td>
+            <td>
+              <jx:out value="${credential.getAccreditableId()}"/>
+            </td>
+            <td colspan="2">
+              <jx:out value="${credential.getRoleId()}"/>
+            </td>
+          </tr>
+        </jx:forEach>
+        
       </table>
     </div>
   </page:body>



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@lenya.apache.org
For additional commands, e-mail: commits-help@lenya.apache.org


Mime
View raw message