You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lenya.apache.org by an...@apache.org on 2003/07/14 20:05:03 UTC

cvs commit: cocoon-lenya/src/java/org/apache/lenya/cms/ac2/file FileAccreditableManager.java

andreas     2003/07/14 11:05:03

  Modified:    src/java/org/apache/lenya/cms/ac2/file
                        FileAccreditableManager.java
  Log:
  improved SourceResolver handling
  
  Revision  Changes    Path
  1.3       +23 -32    cocoon-lenya/src/java/org/apache/lenya/cms/ac2/file/FileAccreditableManager.java
  
  Index: FileAccreditableManager.java
  ===================================================================
  RCS file: /home/cvs/cocoon-lenya/src/java/org/apache/lenya/cms/ac2/file/FileAccreditableManager.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- FileAccreditableManager.java	11 Jul 2003 13:24:37 -0000	1.2
  +++ FileAccreditableManager.java	14 Jul 2003 18:05:03 -0000	1.3
  @@ -103,8 +103,6 @@
       }
   
       private File configurationDirectory;
  -    protected static final String POLICY_PATH = "policies";
  -    protected static final String ACCREDITABLE_PATH = "passwd";
   
       /**
        * Returns the configuration directory.
  @@ -114,16 +112,28 @@
       public File getConfigurationDirectory() throws AccessControlException {
   
           if (configurationDirectory == null) {
  -            Source source;
  +            Source source = null;
  +            SourceResolver resolver = null;
               File directory;
               try {
                   getLogger().debug("Configuration directory Path: " + configurationDirectoryPath);
  -                source = getResolver().resolveURI(configurationDirectoryPath);
  +                
  +                resolver = (SourceResolver) getManager().lookup(SourceResolver.ROLE);
  +                source = resolver.resolveURI(configurationDirectoryPath);
  +                
                   getLogger().debug("Configuration directory URI: " + source.getURI());
                   directory = new File(new URI(source.getURI()));
               } catch (Exception e) {
                   throw new AccessControlException(e);
               }
  +            finally {
  +                if (resolver != null) {
  +                    if (source != null) {
  +                        resolver.release(source);
  +                    }
  +                    getManager().release(resolver);
  +                }
  +            }
               setConfigurationDirectory(directory);
           }
   
  @@ -131,34 +141,24 @@
       }
   
       /**
  -     * Returns the directory where accreditables are configured.
  -     * @return A file.
  -     * @throws AccessControlException when something went wrong.
  -     */
  -    protected File getAccreditableConfigurationDirectory()
  -        throws AccessControlException {
  -        return new File(getConfigurationDirectory(), ACCREDITABLE_PATH);
  -    }
  -
  -    /**
        * @see org.apache.lenya.cms.ac2.AccreditableManager#getUserManager()
        */
       public UserManager getUserManager() throws AccessControlException {
  -        return UserManager.instance(getAccreditableConfigurationDirectory());
  +        return UserManager.instance(getConfigurationDirectory());
       }
   
       /**
        * @see org.apache.lenya.cms.ac2.AccreditableManager#getGroupManager()
        */
       public GroupManager getGroupManager() throws AccessControlException {
  -        return GroupManager.instance(getAccreditableConfigurationDirectory());
  +        return GroupManager.instance(getConfigurationDirectory());
       }
   
       /**
        * @see org.apache.lenya.cms.ac2.AccreditableManager#getRoleManager()
        */
       public RoleManager getRoleManager() throws AccessControlException {
  -        return RoleManager.instance(getAccreditableConfigurationDirectory());
  +        return RoleManager.instance(getConfigurationDirectory());
       }
   
       protected static final String DIRECTORY = "directory";
  @@ -174,19 +174,20 @@
           }
       }
   
  -    private String configurationDirectoryPath = "config/ac";
  +    private String configurationDirectoryPath;
   
       /**
        * Sets the configuration directory.
        * @param file The configuration directory.
        */
  -    public void setConfigurationDirectory(File file) {
  -        assert(file != null) && file.isDirectory();
  +    public void setConfigurationDirectory(File file) throws AccessControlException {
  +        if (file == null || !file.isDirectory()) {
  +            throw new AccessControlException("Configuration directory [" + file + "] does not exist!");
  +        }
           configurationDirectory = file;
       }
   
       private ServiceManager manager;
  -    private SourceResolver resolver;
   
       /**
        * Set the global component manager.
  @@ -196,8 +197,6 @@
        */
       public void service(ServiceManager manager) throws ServiceException {
           this.manager = manager;
  -        this.resolver =
  -            (SourceResolver) this.manager.lookup(SourceResolver.ROLE);
       }
   
       /**
  @@ -206,14 +205,6 @@
        */
       protected ServiceManager getManager() {
           return manager;
  -    }
  -
  -    /**
  -     * Returns the source resolver.
  -     * @return A source resolver.
  -     */
  -    protected SourceResolver getResolver() {
  -        return resolver;
       }
   
   }
  
  
  

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