You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by cz...@apache.org on 2003/05/26 12:15:03 UTC

cvs commit: cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/coplet/adapter CopletAdapter.java

cziegeler    2003/05/26 03:15:02

  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
  Log:
  Using relative uris for coplets
  
  Revision  Changes    Path
  1.4       +12 -12    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.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- portal.xml	22 May 2003 12:32:48 -0000	1.3
  +++ portal.xml	26 May 2003 10:15:00 -0000	1.4
  @@ -6,7 +6,7 @@
         <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://samples/portal/news/newsweek.rss</value>
  +      	<value xsi:type="java:java.lang.String" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">cocoon:/news/newsweek.rss</value>
         </attribute>
      </coplet-data>
   
  @@ -16,7 +16,7 @@
         <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://samples/portal/news/NYTBusiness.rss</value>
  +      	<value xsi:type="java:java.lang.String" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">cocoon:/news/NYTBusiness.rss</value>
         </attribute>
      </coplet-data>
   
  @@ -26,7 +26,7 @@
         <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://samples/portal/news/BBCNews.rss</value>
  +      	<value xsi:type="java:java.lang.String" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">cocoon:/news/BBCNews.rss</value>
         </attribute>
      </coplet-data>
   
  @@ -36,7 +36,7 @@
         <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://samples/portal/news/CNET_news.rss</value>
  +      	<value xsi:type="java:java.lang.String" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">cocoon:/news/CNET_news.rss</value>
         </attribute>
      </coplet-data>
   
  @@ -46,7 +46,7 @@
         <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://samples/portal/news/CNET_business.rss</value>
  +      	<value xsi:type="java:java.lang.String" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">cocoon:/news/CNET_business.rss</value>
         </attribute>
      </coplet-data>
   
  @@ -56,7 +56,7 @@
         <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://samples/portal/news/CSTNews.rss</value>
  +      	<value xsi:type="java:java.lang.String" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">cocoon:/news/CSTNews.rss</value>
         </attribute>
      </coplet-data>
   
  @@ -66,7 +66,7 @@
         <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://samples/portal/news/CNNEurope.rss</value>
  +      	<value xsi:type="java:java.lang.String" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">cocoon:/news/CNNEurope.rss</value>
         </attribute>
      </coplet-data>
   
  @@ -76,7 +76,7 @@
         <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://samples/portal/news/ML_weblog.rss</value>
  +      	<value xsi:type="java:java.lang.String" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">cocoon:/news/ML_weblog.rss</value>
         </attribute>
      </coplet-data>
   
  @@ -86,7 +86,7 @@
         <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://samples/portal/news/CZ_weblog.rss</value>
  +      	<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>
   
  @@ -96,7 +96,7 @@
         <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://samples/portal/news/weblog.rss</value>
  +      	<value xsi:type="java:java.lang.String" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">cocoon:/news/weblog.rss</value>
         </attribute>
      </coplet-data>
   
  @@ -106,7 +106,7 @@
         <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://samples/portal/news/introduction.html</value>
  +      	<value xsi:type="java:java.lang.String" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">cocoon:/news/introduction.html</value>
         </attribute>
      </coplet-data>
   
  @@ -116,7 +116,7 @@
         <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://samples/portal/news/overview.html</value>
  +      	<value xsi:type="java:java.lang.String" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">cocoon:/news/overview.html</value>
         </attribute>
      </coplet-data>
   </coplets>
  
  
  
  1.7       +13 -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.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- URICopletAdapter.java	26 May 2003 09:52:59 -0000	1.6
  +++ URICopletAdapter.java	26 May 2003 10:15:01 -0000	1.7
  @@ -98,12 +98,23 @@
   		PortalService portalService = null;
   		try {
   			if (uri.startsWith("cocoon:")) {
  +                Boolean handlePars = (Boolean)this.getConfiguration( coplet, "handleParameters");
  +                
  +                String sourceUri = uri;
  +                
  +                if ( handlePars != null && handlePars.booleanValue() ) {
  +                    // remove parameters
  +                    if (!uri.startsWith("cocoon:raw:") ) {
  +                        sourceUri = "cocoon:raw:" + uri.substring(7);
  +                    }
  +                }
  +                
   				portalService = (PortalService)this.manager.lookup(PortalService.ROLE);
   				HashMap par = new HashMap();
   				par.put(Constants.PORTAL_NAME_KEY, portalService.getPortalName());
   				par.put(Constants.COPLET_ID_KEY, coplet.getId());
               
  -				copletSource = this.resolver.resolveURI(uri, null, par);
  +				copletSource = this.resolver.resolveURI(sourceUri, null, par);
   			} else {
   				copletSource = this.resolver.resolveURI(uri);
   			}
  
  
  
  1.3       +16 -5     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.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- AbstractCopletAdapter.java	26 May 2003 09:52:59 -0000	1.2
  +++ AbstractCopletAdapter.java	26 May 2003 10:15:01 -0000	1.3
  @@ -57,6 +57,7 @@
   import org.apache.avalon.framework.thread.ThreadSafe;
   import org.apache.cocoon.components.sax.XMLDeserializer;
   import org.apache.cocoon.components.sax.XMLSerializer;
  +import org.apache.cocoon.portal.coplet.CopletData;
   import org.apache.cocoon.portal.coplet.CopletInstanceData;
   import org.apache.cocoon.portal.coplet.adapter.CopletAdapter;
   import org.apache.cocoon.xml.ContentHandlerWrapper;
  @@ -89,6 +90,19 @@
           this.manager = componentManager;
       }
   
  +    /**
  +     * Get a configuration value
  +     * First the coplet data is queried and if it doesn't provide an
  +     * attribute with the given name, the coplet base data is used.
  +     */
  +    protected Object getConfiguration(CopletInstanceData coplet, String key) {
  +        CopletData copletData = coplet.getCopletData();
  +        Object data = copletData.getAttribute( key );
  +        if ( data == null) {
  +            data = copletData.getCopletBaseData().getCopletConfig().get( key );
  +        }
  +        return data;
  +    }
       
       /**
        * Implement this and not toSAX()
  @@ -99,10 +113,7 @@
       
       public void toSAX(CopletInstanceData coplet, ContentHandler contentHandler)
       throws SAXException {
  -        Boolean bool = (Boolean)coplet.getCopletData().getAttribute("buffer");
  -        if ( bool == null) {
  -            bool = (Boolean)coplet.getCopletData().getCopletBaseData().getCopletConfig().get("buffer");
  -        }
  +        Boolean bool = (Boolean) this.getConfiguration( coplet, "buffer" );
           // FIXME - remove this
           bool = new Boolean(true);
           
  
  
  
  1.4       +18 -1     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.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- CopletAdapter.java	26 May 2003 09:52:59 -0000	1.3
  +++ CopletAdapter.java	26 May 2003 10:15:01 -0000	1.4
  @@ -63,6 +63,20 @@
    * Whenever an instance of this coplet is rendered, the
    * adapter is invoked to render the coplet.
    * 
  + * The behaviour of the adapter can be controlled by a set of
  + * parameters. In general, the coplet base data defines the default
  + * for all coplets, but the value can be overriden by the coplet
  + * data. The coplet base data stores the information in the coplet
  + * config map whereas the coplet data stores them in the attributes.
  + * Apart from that the keys and the data types are the same.
  + * 
  + * Configuration:
  + * 
  + * buffer - A boolean value (default is false) that defines if the
  + *          xml data stream from the coplet is buffered. If the stream
  + *          is not buffered and an exception occurs then the whole
  + *          portal will be rendered invalid.
  + * 
    * @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>
    * 
  @@ -85,6 +99,7 @@
        * 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);
  @@ -99,6 +114,7 @@
        * 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);
           
  @@ -106,6 +122,7 @@
        * 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);
   }