You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by bl...@apache.org on 2001/05/07 18:13:58 UTC

cvs commit: xml-cocoon/src/org/apache/cocoon Cocoon.java

bloritsch    01/05/07 09:13:57

  Modified:    src/org/apache/cocoon Tag: xml-cocoon2 Cocoon.java
  Log:
  User-Roles completed.
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.4.2.82  +32 -2     xml-cocoon/src/org/apache/cocoon/Cocoon.java
  
  Index: Cocoon.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/Cocoon.java,v
  retrieving revision 1.4.2.81
  retrieving revision 1.4.2.82
  diff -u -r1.4.2.81 -r1.4.2.82
  --- Cocoon.java	2001/04/30 14:16:53	1.4.2.81
  +++ Cocoon.java	2001/05/07 16:13:51	1.4.2.82
  @@ -11,6 +11,8 @@
   import java.io.FileNotFoundException;
   import java.io.IOException;
   import java.io.InputStream;
  +import java.io.FileInputStream;
  +import java.io.BufferedInputStream;
   import java.net.URL;
   import java.util.Enumeration;
   import java.util.HashMap;
  @@ -52,7 +54,7 @@
    *
    * @author <a href="mailto:fumagalli@exoffice.com">Pierpaolo Fumagalli</a> (Apache Software Foundation, Exoffice Technologies)
    * @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
  - * @version CVS $Revision: 1.4.2.81 $ $Date: 2001/04/30 14:16:53 $
  + * @version CVS $Revision: 1.4.2.82 $ $Date: 2001/05/07 16:13:51 $
    */
   public class Cocoon extends AbstractLoggable implements ThreadSafe, Component, Initializable, Disposable, Modifiable, Processor, Contextualizable {
       /** The application context */
  @@ -162,7 +164,6 @@
           DefaultRoleManager drm = new DefaultRoleManager();
           drm.setLogger(getLogger());
           drm.configure(roleConfig);
  -        this.componentManager.setRoleManager(drm);
           roleConfig = null;
   
           try {
  @@ -190,6 +191,35 @@
           if (Constants.CONF_VERSION.equals(conf.getAttribute("version")) == false) {
               throw new ConfigurationException("Invalid configuration schema version. Must be '" + Constants.CONF_VERSION + "'.");
           }
  +
  +        String userRoles = conf.getAttribute("user-roles", "");
  +        if ("".equals(userRoles) == false) {
  +            try {
  +                p = (Parser)this.componentManager.lookup(Roles.PARSER);
  +                SAXConfigurationHandler b = new SAXConfigurationHandler();
  +                ClassLoader cl = (ClassLoader) this.context.get(Constants.CONTEXT_CLASS_LOADER);
  +                File location = new File(new File((String)this.context.get(Constants.CONTEXT_ROOT_PATH)), userRoles);
  +                InputSource is = new InputSource(new BufferedInputStream(new FileInputStream(location)));
  +                p.setContentHandler(b);
  +                is.setSystemId(this.configurationFile.toExternalForm());
  +                p.parse(is);
  +                roleConfig = b.getConfiguration();
  +            } catch (Exception e) {
  +                getLogger().error("Could not configure Cocoon environment", e);
  +                throw new ConfigurationException("Error trying to load configurations", e);
  +            } finally {
  +                if (p != null) this.componentManager.release((Component) p);
  +            }
  +
  +            DefaultRoleManager urm = new DefaultRoleManager(drm);
  +            urm.setLogger(getLogger());
  +            urm.configure(roleConfig);
  +            roleConfig = null;
  +            drm = urm;
  +        }
  +
  +        this.componentManager.setRoleManager(drm);
  +
           getLogger().debug("Setting up components...");
           this.componentManager.configure(conf);
           getLogger().debug("Setting up the sitemap.");
  
  
  

----------------------------------------------------------------------
In case of troubles, e-mail:     webmaster@xml.apache.org
To unsubscribe, e-mail:          cocoon-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-cvs-help@xml.apache.org