lenya-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From andr...@apache.org
Subject cvs commit: cocoon-lenya/src/java/org/apache/lenya/cms/ac2/xsp CredentialWrapper.java PolicyHelper.java
Date Wed, 06 Aug 2003 13:06:00 GMT
andreas     2003/08/06 06:06:00

  Modified:    src/java/org/apache/lenya/cms/ac2/xsp CredentialWrapper.java
                        PolicyHelper.java
  Log:
  added some javadocs
  
  Revision  Changes    Path
  1.2       +15 -5     cocoon-lenya/src/java/org/apache/lenya/cms/ac2/xsp/CredentialWrapper.java
  
  Index: CredentialWrapper.java
  ===================================================================
  RCS file: /home/cvs/cocoon-lenya/src/java/org/apache/lenya/cms/ac2/xsp/CredentialWrapper.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- CredentialWrapper.java	24 Jul 2003 18:36:35 -0000	1.1
  +++ CredentialWrapper.java	6 Aug 2003 13:06:00 -0000	1.2
  @@ -22,40 +22,50 @@
   public class CredentialWrapper {
   
       /**
  -     * @return
  +     * Returns the accreditable ID.
  +     * @return A string.
        */
       public String getAccreditableId() {
           return accreditableId;
       }
   
       /**
  -     * @return
  +     * Returns the accreditable name.
  +     * @return A string.
        */
       public String getAccreditableName() {
           return accreditableName;
       }
   
       /**
  -     * @return
  +     * Returns the role ID.
  +     * @return A string.
        */
       public String getRoleId() {
           return roleId;
       }
   
       /**
  -     * @return
  +     * Returns the role name.
  +     * @return A string.
        */
       public String getRoleName() {
           return roleName;
       }
   
       /**
  -     * @return
  +     * Returns the accreditable type ({@link #USER}, {@link GROUP}, or {@link IPRANGE})
  +     * @return A string.
        */
       public String getType() {
           return type;
       }
   
  +    /**
  +     * Ctor.
  +     * @param accreditable The accreditable of the credential to wrap.
  +     * @param role The role of the credential to wrap.
  +     */
       public CredentialWrapper(Accreditable accreditable, Role role) {
           if (accreditable instanceof Item) {
               Item item = (Item) accreditable;
  
  
  
  1.4       +75 -12    cocoon-lenya/src/java/org/apache/lenya/cms/ac2/xsp/PolicyHelper.java
  
  Index: PolicyHelper.java
  ===================================================================
  RCS file: /home/cvs/cocoon-lenya/src/java/org/apache/lenya/cms/ac2/xsp/PolicyHelper.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- PolicyHelper.java	30 Jul 2003 15:03:25 -0000	1.3
  +++ PolicyHelper.java	6 Aug 2003 13:06:00 -0000	1.4
  @@ -80,12 +80,26 @@
   import org.apache.lenya.cms.publication.PageEnvelopeFactory;
   
   /**
  + * Helper class for the policy GUI.
  + * 
    * @author andreas
    */
  -public class PolicyHelper {
  -
  -    protected static final String DEFAULT_RESOLVER = "composable";
  +public final class PolicyHelper {
  +    
  +    /**
  +     * Ctor.
  +     */
  +    private PolicyHelper() {
  +    }
   
  +    /**
  +     * Returns the URI credential wrappers for the request of this object model.
  +     * @param objectModel The Cocoon object model.
  +     * @param area The selected area.
  +     * @param manager The ComponentManager to use.
  +     * @return An array of CredentialWrappers.
  +     * @throws ProcessingException when something went wrong.
  +     */
       public static CredentialWrapper[] getURICredentials(
           Map objectModel,
           String area,
  @@ -94,6 +108,15 @@
           return getCredentials(objectModel, area, manager, true);
       }
   
  +    /**
  +     * Returns the credential wrappers for the parent URI of the URL
  +     * belonging to the request of this object model.
  +     * @param objectModel The Cocoon object model.
  +     * @param area The selected area.
  +     * @param manager The ComponentManager to use.
  +     * @return An array of CredentialWrappers.
  +     * @throws ProcessingException when something went wrong.
  +     */
       public static CredentialWrapper[] getParentCredentials(
           Map objectModel,
           String area,
  @@ -102,6 +125,16 @@
           return getCredentials(objectModel, area, manager, false);
       }
   
  +    /**
  +     * Returns the credentials of the policy of the selected URL.
  +     * @param objectModel The Cocoon object model.
  +     * @param area The selected area.
  +     * @param manager The ComponentManager to use.
  +     * @param urlOnly If true, the URL policy credentials are returned.
  +     * If false, the credentials of all ancestor policies are returned.
  +     * @return An array of CredentialWrappers.
  +     * @throws ProcessingException when something went wrong.
  +     */
       public static CredentialWrapper[] getCredentials(
           Map objectModel,
           String area,
  @@ -120,7 +153,9 @@
           try {
               selector =
                   (ComponentSelector) manager.lookup(AccessControllerResolver.ROLE + "Selector");
  -            resolver = (AccessControllerResolver) selector.select(DEFAULT_RESOLVER);
  +            resolver =
  +                (AccessControllerResolver) selector.select(
  +                    AccessControllerResolver.DEFAULT_RESOLVER);
   
               accessController = (DefaultAccessController) resolver.resolveAccessController(url);
   
  @@ -162,6 +197,14 @@
           return (CredentialWrapper[]) credentials.toArray(new CredentialWrapper[credentials.size()]);
       }
   
  +    /**
  +     * Computes the webapp URL belonging to an object model with respect to the selected
  +     * area.
  +     * @param objectModel The Cocoon object model.
  +     * @param area The selected area.
  +     * @return A string.
  +     * @throws ProcessingException when something went wrong.
  +     */
       private static String computeUrl(Map objectModel, String area) throws ProcessingException
{
           PageEnvelope envelope;
           try {
  @@ -174,6 +217,16 @@
           return url;
       }
   
  +    /**
  +     * Returns the policies for a certain URL.
  +     * @param accreditableManager The accreditable manager to use.
  +     * @param policyManager The policy manager to use.
  +     * @param url The URL to get the policies for.
  +     * @param onlyUrl If true, only the URL policies are returned.
  +     * Otherwise, all ancestor policies are returned.
  +     * @return An array of DefaultPolicy objects.
  +     * @throws AccessControlException when something went wrong.
  +     */
       protected static DefaultPolicy[] getPolicies(
           AccreditableManager accreditableManager,
           InheritingPolicyManager policyManager,
  @@ -198,10 +251,20 @@
   
           return policies;
       }
  -    
  +
       public static final String ADD = "add";
       public static final String DELETE = "delete";
   
  +    /**
  +     * Changes a credential by adding or deleting an item for a role.
  +     * @param objectModel The Cocoon object model.
  +     * @param item The item to add or delete.
  +     * @param role The role.
  +     * @param area The selected area.
  +     * @param operation The operation, either {@link #ADD} or {@link #DELETE}.
  +     * @param manager The ComponentManager to use.
  +     * @throws ProcessingException when something went wrong.
  +     */
       public static void manipulateCredential(
           Map objectModel,
           Item item,
  @@ -221,7 +284,9 @@
           try {
               selector =
                   (ComponentSelector) manager.lookup(AccessControllerResolver.ROLE + "Selector");
  -            resolver = (AccessControllerResolver) selector.select(DEFAULT_RESOLVER);
  +            resolver =
  +                (AccessControllerResolver) selector.select(
  +                    AccessControllerResolver.DEFAULT_RESOLVER);
   
               accessController = (DefaultAccessController) resolver.resolveAccessController(url);
   
  @@ -231,16 +296,14 @@
               DefaultPolicy policy = policyManager.buildSubtreePolicy(accreditableManager,
url);
   
               Accreditable accreditable = (Accreditable) item;
  -            
  +
               if (operation.equals(ADD)) {
                   policy.addRole(accreditable, role);
  -            }
  -            else if (operation.equals(DELETE)) {
  +            } else if (operation.equals(DELETE)) {
                   policy.removeRole(accreditable, role);
               }
  -            
  +
               policyManager.saveSubtreePolicy(url, policy);
  -            
   
           } catch (Exception e) {
               throw new ProcessingException("Manipulating credential failed: ", e);
  
  
  

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


Mime
View raw message