cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject cvs commit: cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/profile/impl StaticProfileManager.java AuthenticationProfileManager.java
Date Tue, 27 May 2003 14:07:17 GMT
cziegeler    2003/05/27 07:07:16

  Modified:    src/blocks/portal/samples/profiles/copletdata portal.xml
               src/blocks/portal/java/org/apache/cocoon/portal/coplet/adapter/impl
                        URICopletAdapter.java AbstractCopletAdapter.java
               src/blocks/portal/java/org/apache/cocoon/portal/coplet/adapter
                        CopletAdapter.java
               src/blocks/portal/java/org/apache/cocoon/portal/profile
                        ProfileManager.java
               src/blocks/portal/samples/profiles/mapping layout.xml
               src/blocks/portal/samples/news sitemap.xmap
               src/blocks/portal/java/org/apache/cocoon/portal/profile/impl
                        StaticProfileManager.java
                        AuthenticationProfileManager.java
  Log:
  Fixing mapping
  Adding error-content
  
  Revision  Changes    Path
  1.5       +8 -0      cocoon-2.1/src/blocks/portal/samples/profiles/copletdata/portal.xml
  
  Index: portal.xml
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/portal/samples/profiles/copletdata/portal.xml,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- portal.xml	26 May 2003 10:15:00 -0000	1.4
  +++ portal.xml	27 May 2003 14:07:16 -0000	1.5
  @@ -86,6 +86,14 @@
         <coplet-base-data>URICoplet</coplet-base-data>
         <attribute>
         	<name>uri</name>
  +      	<value xsi:type="java:java.lang.String" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">cocoon:/news/liverss?feed=http://radio.weblogs.com/0107211/rss.xml</value>
  +      </attribute>
  +      <attribute>
  +      	<name>buffer</name>
  +      	<value xsi:type="java:java.lang.Boolean" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">true</value>
  +      </attribute>
  +      <attribute>
  +      	<name>error-uri</name>
         	<value xsi:type="java:java.lang.String" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">cocoon:/news/CZ_weblog.rss</value>
         </attribute>
      </coplet-data>
  
  
  
  1.10      +30 -2     cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/coplet/adapter/impl/URICopletAdapter.java
  
  Index: URICopletAdapter.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/coplet/adapter/impl/URICopletAdapter.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- URICopletAdapter.java	26 May 2003 12:49:14 -0000	1.9
  +++ URICopletAdapter.java	27 May 2003 14:07:16 -0000	1.10
  @@ -101,7 +101,14 @@
       
       public void streamContent(CopletInstanceData coplet, ContentHandler contentHandler)
       throws SAXException {
  -		final String uri = (String)coplet.getCopletData().getAttribute("uri");
  +        final String uri = (String)coplet.getCopletData().getAttribute("uri");
  +        this.streamContent( coplet, uri, contentHandler);
  +    }
  +
  +    public void streamContent(final CopletInstanceData coplet, 
  +                               final String uri,
  +                               final ContentHandler contentHandler)
  +    throws SAXException {
   		Source copletSource = null;
   		PortalService portalService = null;
   		try {
  @@ -213,6 +220,27 @@
           } finally {
               this.manager.release( eventManager );
           }
  +    }
  +
  +    /**
  +     * Render the error content for a coplet
  +     * @param coplet
  +     * @param handler
  +     * @return True if the error content has been rendered, otherwise false
  +     * @throws SAXException
  +     */
  +    protected boolean renderErrorContent(CopletInstanceData coplet, ContentHandler handler)
  +    throws SAXException {
  +        final String uri = (String) this.getConfiguration(coplet, "error-uri");
  +        if ( uri != null ) {
  +            // TODO - if an error occured for this coplet, remember this
  +            //         and use directly the error-uri from now on
  +            // We need for this the ability to dynamically add aspects to
  +            // objects!
  +            this.streamContent( coplet, uri, handler);
  +            return true;
  +        }
  +        return false;
       }
   
   }
  
  
  
  1.4       +23 -10    cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/coplet/adapter/impl/AbstractCopletAdapter.java
  
  Index: AbstractCopletAdapter.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/coplet/adapter/impl/AbstractCopletAdapter.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- AbstractCopletAdapter.java	26 May 2003 10:15:01 -0000	1.3
  +++ AbstractCopletAdapter.java	27 May 2003 14:07:16 -0000	1.4
  @@ -69,6 +69,8 @@
   
   /**
    * This is the adapter to use pipelines as coplets
  + * 
  + * TODO - implement timeout
    *
    * @author <a href="mailto:cziegeler@s-und-n.de">Carsten Ziegeler</a>
    * @author <a href="mailto:volker.schmitt@basf-it-services.com">Volker Schmitt</a>
  @@ -114,9 +116,7 @@
       public void toSAX(CopletInstanceData coplet, ContentHandler contentHandler)
       throws SAXException {
           Boolean bool = (Boolean) this.getConfiguration( coplet, "buffer" );
  -        // FIXME - remove this
  -        bool = new Boolean(true);
  -        
  +
           if ( bool != null && bool.booleanValue() ) {
               boolean read = false;
               XMLSerializer serializer = null;
  @@ -152,12 +152,14 @@
                       this.manager.release( deserializer );
                   }
               } else {
  -                // FIXME - get correct error message
  -                contentHandler.startDocument();
  -                XMLUtils.startElement( contentHandler, "p");
  -                XMLUtils.data( contentHandler, "The coplet " + coplet.getId() + " is currently
not available.");
  -                XMLUtils.endElement(contentHandler, "p");
  -                contentHandler.endDocument();                
  +                if ( !this.renderErrorContent(coplet, contentHandler)) {
  +                    // FIXME - get correct error message
  +                    contentHandler.startDocument();
  +                    XMLUtils.startElement( contentHandler, "p");
  +                    XMLUtils.data( contentHandler, "The coplet " + coplet.getId() + " is
currently not available.");
  +                    XMLUtils.endElement(contentHandler, "p");
  +                    contentHandler.endDocument();                
  +                }
               }
           } else {
               this.streamContent( coplet, contentHandler );
  @@ -177,4 +179,15 @@
       public void logout(CopletInstanceData coplet) {
       }
       
  +    /**
  +     * Render the error content for a coplet
  +     * @param coplet
  +     * @param handler
  +     * @return True if the error content has been rendered, otherwise false
  +     * @throws SAXException
  +     */
  +    protected boolean renderErrorContent(CopletInstanceData coplet, ContentHandler handler)
  +    throws SAXException {
  +        return false;
  +    }
   }
  
  
  
  1.5       +1 -4      cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/coplet/adapter/CopletAdapter.java
  
  Index: CopletAdapter.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/coplet/adapter/CopletAdapter.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- CopletAdapter.java	26 May 2003 10:15:01 -0000	1.4
  +++ CopletAdapter.java	27 May 2003 14:07:16 -0000	1.5
  @@ -99,7 +99,6 @@
        * Destroy the coplet
        * This method is invoked when a coplet instance will be destroyed
        * For each coplet, this method is only invoked once.
  -     * TODO - not implemented yet
        * @param coplet
        */
       void destroy(CopletInstanceData coplet);
  @@ -114,7 +113,6 @@
        * User logs in to a coplet
        * This method is invoked when a user logs in for each coplet instance
        * of the user
  -     * TODO - not implemented yet
        */
       void login(CopletInstanceData coplet);
           
  @@ -122,7 +120,6 @@
        * User logs out from a coplet
        * This method is invoked when a user logs out for each coplet instance
        * of this user.
  -     * TODO - not implemented yet
        */
       void logout(CopletInstanceData coplet);
   }
  
  
  
  1.5       +7 -1      cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/profile/ProfileManager.java
  
  Index: ProfileManager.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/profile/ProfileManager.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- ProfileManager.java	27 May 2003 09:15:07 -0000	1.4
  +++ ProfileManager.java	27 May 2003 14:07:16 -0000	1.5
  @@ -79,6 +79,12 @@
       
       List getCopletInstanceData(CopletData data);
       
  +    // TODO - not called yet
  +    void login();
  +    
  +    // TODO - not called yet
  +    void logout();
  +    
       void register(CopletInstanceData coplet);
       
       void unregister(CopletInstanceData coplet);
  
  
  
  1.12      +4 -1      cocoon-2.1/src/blocks/portal/samples/profiles/mapping/layout.xml
  
  Index: layout.xml
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/portal/samples/profiles/mapping/layout.xml,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- layout.xml	27 May 2003 09:17:33 -0000	1.11
  +++ layout.xml	27 May 2003 14:07:16 -0000	1.12
  @@ -49,7 +49,10 @@
       <class name="org.apache.cocoon.portal.layout.impl.CompositeLayoutImpl"
              extends="org.apache.cocoon.portal.layout.AbstractLayout">
           <map-to xml="composite-layout"/>
  -        <field name="items" type="org.apache.cocoon.portal.layout.Item" collection="collection"
set-method="addItem">
  +        <field name="items" type="org.apache.cocoon.portal.layout.Item" 
  +               collection="collection" 
  +               set-method="addItem"
  +               get-method="getItems">
               <bind-xml auto-naming="deriveByClass" />
           </field>
       </class>
  
  
  
  1.2       +7 -13     cocoon-2.1/src/blocks/portal/samples/news/sitemap.xmap
  
  Index: sitemap.xmap
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/portal/samples/news/sitemap.xmap,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- sitemap.xmap	7 May 2003 06:22:30 -0000	1.1
  +++ sitemap.xmap	27 May 2003 14:07:16 -0000	1.2
  @@ -1,20 +1,9 @@
   <?xml version="1.0"?>
  -
   <map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0">
  -<!-- =========================== Components ================================ -->
  -<!-- =========================== Views =================================== -->
  -
  - <map:views>
  -  <map:view name="content" from-label="content">
  -   <map:serialize type="xml"/>
  -  </map:view>
  - </map:views>
  -<!-- =========================== Pipelines ================================= -->
   
    <map:pipelines>
  -  <!-- News Portal2 Demo Pipelines. Structure like forrest seed. -->
  -		
  -  <map:pipeline>	
  +    
  +    <map:pipeline>	
   
       <map:match pattern="images/*.gif">
           <map:read mime-type="image/gif" src="content/resources/images/{1}.gif"/>
  @@ -26,6 +15,11 @@
           <map:generate type="file" src="content/xdocs/{1}.xml" label="content" />
           <map:transform type="xslt" src="content/resources/xsl/document2html.xsl"/>
           <map:serialize type="html"/>
  +    </map:match>
  +    <map:match pattern="liverss">
  +        <map:generate type="file" src="{request-param:feed}" label="content" />
  +        <map:transform type="xslt" src="content/resources/xsl/rss2html_news.xsl"/>
  +        <map:serialize type="xml"/>
       </map:match>
       <map:match pattern="*.rss">
           <map:generate type="file" src="content/rss/{1}.xml" label="content" />
  
  
  
  1.2       +8 -1      cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/profile/impl/StaticProfileManager.java
  
  Index: StaticProfileManager.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/profile/impl/StaticProfileManager.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- StaticProfileManager.java	27 May 2003 11:54:18 -0000	1.1
  +++ StaticProfileManager.java	27 May 2003 14:07:16 -0000	1.2
  @@ -280,4 +280,11 @@
   
       public void saveUserProfiles() {
       }
  +    
  +    public void login() {
  +    }
  +    
  +    public void logout() {
  +    }
  +    
   }
  
  
  
  1.3       +55 -6     cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/profile/impl/AuthenticationProfileManager.java
  
  Index: AuthenticationProfileManager.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/profile/impl/AuthenticationProfileManager.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- AuthenticationProfileManager.java	27 May 2003 12:24:36 -0000	1.2
  +++ AuthenticationProfileManager.java	27 May 2003 14:07:16 -0000	1.3
  @@ -61,6 +61,7 @@
   import org.apache.avalon.framework.component.Component;
   import org.apache.avalon.framework.component.ComponentException;
   import org.apache.avalon.framework.component.ComponentManager;
  +import org.apache.avalon.framework.component.ComponentSelector;
   import org.apache.avalon.framework.component.Composable;
   import org.apache.avalon.framework.logger.AbstractLogEnabled;
   import org.apache.avalon.framework.thread.ThreadSafe;
  @@ -69,6 +70,7 @@
   import org.apache.cocoon.portal.coplet.CopletData;
   import org.apache.cocoon.portal.coplet.CopletFactory;
   import org.apache.cocoon.portal.coplet.CopletInstanceData;
  +import org.apache.cocoon.portal.coplet.adapter.CopletAdapter;
   import org.apache.cocoon.portal.layout.CompositeLayout;
   import org.apache.cocoon.portal.layout.Item;
   import org.apache.cocoon.portal.layout.Layout;
  @@ -81,7 +83,6 @@
   import org.apache.commons.lang.exception.ExceptionUtils;
   import org.apache.excalibur.source.SourceNotFoundException;
   import org.apache.excalibur.source.SourceValidity;
  -import org.exolab.castor.mapping.Mapping;
   
   /**
    * The profile manager using the authentication framework
  @@ -99,10 +100,6 @@
   
       protected ComponentManager manager;
   
  -    private Mapping layoutMapping;
  -
  -    private Map layoutStati = new HashMap(100);
  -    
       private Map attributes = new HashMap();
       
       private ReadWriteLock lock = new ReadWriteLock();
  @@ -127,6 +124,42 @@
           }
       }
       
  +    public void login() {
  +        // TODO - we should move most of the stuff from getPortalLayout to here
  +        // for now we use a hack :)
  +        this.getPortalLayout(null);
  +    }
  +    
  +    public void logout() {
  +        PortalService service = null;
  +        String attribute = null;
  +        ComponentSelector adapterSelector = null;
  +        try {
  +            adapterSelector = (ComponentSelector)this.manager.lookup(CopletAdapter.ROLE+"Selector");
  +            service = (PortalService) this.manager.lookup(PortalService.ROLE);
  +
  +            attribute = AuthenticationProfileManager.class.getName()+"/"+service.getPortalName()+"/CopletInstanceData";
  +            CopletInstanceDataManager copletInstanceDataManager = (CopletInstanceDataManager)service.getAttribute(attribute);
  +            
  +            Iterator iter = copletInstanceDataManager.getCopletInstanceData().values().iterator();
  +            while ( iter.hasNext() ) {
  +                CopletInstanceData cid = (CopletInstanceData) iter.next();
  +                CopletAdapter adapter = null;
  +                try {
  +                    adapter = (CopletAdapter) adapterSelector.select(cid.getCopletData().getCopletBaseData().getCopletAdapterName());
  +                    adapter.logout( cid );
  +                } finally {
  +                    adapterSelector.release( adapter );
  +                }
  +            }
  +        } catch (ComponentException e) {
  +            throw new CascadingRuntimeException("Unable to lookup portal service.", e);
  +        } finally {
  +            this.manager.release(service);
  +            this.manager.release(adapterSelector);
  +        }        
  +    }
  +    
       /**
        * @see org.apache.cocoon.portal.profile.ProfileManager#getPortalLayout(Object)
        */
  @@ -134,11 +167,13 @@
           PortalService service = null;
           LayoutFactory factory = null;
           CopletFactory copletFactory = null;
  +        ComponentSelector adapterSelector = null;
           
           try {
               service = (PortalService) this.manager.lookup(PortalService.ROLE);
               factory = (LayoutFactory) this.manager.lookup(LayoutFactory.ROLE);
               copletFactory = (CopletFactory) this.manager.lookup(CopletFactory.ROLE);
  +            adapterSelector = (ComponentSelector)this.manager.lookup(CopletAdapter.ROLE+"Selector");
               
               if ( null == key ) {
                   Layout l = (Layout) service.getTemporaryAttribute("DEFAULT_LAYOUT");
  @@ -205,6 +240,19 @@
   					map.put("profile", "layout");
   					map.put("objectmap", copletInstanceDataManager.getCopletInstanceData());
   					layout = (Layout)this.getOrCreateProfile(keyMap, map, portalPrefix+"/Layout", service,
factory);
  +                    
  +                    // now invoke login on each instance
  +                    Iterator iter =  copletInstanceDataManager.getCopletInstanceData().values().iterator();
  +                    while ( iter.hasNext() ) {
  +                        CopletInstanceData cid = (CopletInstanceData) iter.next();
  +                        CopletAdapter adapter = null;
  +                        try {
  +                            adapter = (CopletAdapter) adapterSelector.select(cid.getCopletData().getCopletBaseData().getCopletAdapterName());
  +                            adapter.login( cid );
  +                        } finally {
  +                            adapterSelector.release( adapter );
  +                        }
  +                    }
   				} finally {
   					this.lock.releaseLocks();
   				}
  @@ -218,6 +266,7 @@
               this.manager.release(service);
               this.manager.release((Component)factory);
               this.manager.release((Component)copletFactory);
  +            this.manager.release(adapterSelector);
           }
       }
       
  
  
  

Mime
View raw message