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/coplet/adapter/impl URICopletAdapter.java
Date Mon, 26 May 2003 12:49:14 GMT
cziegeler    2003/05/26 05:49:14

  Modified:    src/blocks/portal/java/org/apache/cocoon/portal/layout
                        CompositeLayout.java
               src/blocks/portal/java/org/apache/cocoon/portal/event/impl
                        ChangeAspectDataEvent.java AbstractActionEvent.java
                        ChangeCopletInstanceAspectDataEvent.java
                        LayoutRemoveEvent.java LinkEvent.java
                        DefaultEventManager.java
               src/blocks/portal/java/org/apache/cocoon/portal/layout/renderer/aspect/impl
                        RemovableAspect.java
               src/blocks/portal/java/org/apache/cocoon/portal/transformation
                        CopletTransformer.java EventLinkTransformer.java
               src/blocks/portal/java/org/apache/cocoon/portal/event/subscriber/impl
                        DefaultChangeAspectDataEventSubscriber.java
               src/blocks/portal/java/org/apache/cocoon/portal/event
                        ActionEvent.java CopletInstanceEvent.java
                        LayoutEvent.java
               src/blocks/portal/java/org/apache/cocoon/portal/coplet/adapter/impl
                        URICopletAdapter.java
  Added:       src/blocks/portal/java/org/apache/cocoon/portal/layout/renderer/aspect/impl
                        AbstractActionAspect.java
               src/blocks/portal/java/org/apache/cocoon/portal/transformation
                        AbstractCopletTransformer.java
  Removed:     src/blocks/portal/java/org/apache/cocoon/portal/event/subscriber/impl
                        DefaultLayoutEventSubscriber.java
  Log:
  Fixing NPE, refactoring
  
  Revision  Changes    Path
  1.5       +2 -1      cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/layout/CompositeLayout.java
  
  Index: CompositeLayout.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/layout/CompositeLayout.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- CompositeLayout.java	26 May 2003 09:52:58 -0000	1.4
  +++ CompositeLayout.java	26 May 2003 12:49:12 -0000	1.5
  @@ -80,6 +80,7 @@
   	 */
   	public final void addItem(int index, Item item) {
   		items.add(index, item);
  +        item.setParent(this);
   	}
   
   	/**
  
  
  
  1.3       +13 -10    cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/event/impl/ChangeAspectDataEvent.java
  
  Index: ChangeAspectDataEvent.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/event/impl/ChangeAspectDataEvent.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ChangeAspectDataEvent.java	26 May 2003 10:34:52 -0000	1.2
  +++ ChangeAspectDataEvent.java	26 May 2003 12:49:13 -0000	1.3
  @@ -51,7 +51,7 @@
   package org.apache.cocoon.portal.event.impl;
   
   import org.apache.cocoon.portal.aspect.Aspectalizable;
  -import org.apache.cocoon.portal.event.Event;
  +import org.apache.cocoon.portal.event.ActionEvent;
   
   /**
    * This events set the aspect data for an {@link Aspectalizable} object
  @@ -61,16 +61,15 @@
    * @version CVS $Id$
    */
   public class ChangeAspectDataEvent
  -    implements Event {
  +    extends AbstractActionEvent
  +    implements ActionEvent {
   
  -    protected Aspectalizable target;
  -    
       protected String aspectName;
       
       protected Object data;
       
       public ChangeAspectDataEvent(Aspectalizable target, String aspectName, Object data)
{
  -        this.target = target;
  +        super(target);
           this.aspectName = aspectName;
           this.data = data;
       }
  @@ -79,21 +78,25 @@
        * @return
        */
       public String getAspectName() {
  -        return aspectName;
  +        return this.aspectName;
       }
   
       /**
        * @return
        */
       public Object getData() {
  -        return data;
  +        return this.data;
       }
   
       /**
        * @return
        */
  -    public Aspectalizable getTarget() {
  -        return target;
  +    public Object getTarget() {
  +        return this.target;
       }
   
  +
  +    public Aspectalizable getAspectalizable() {
  +        return (Aspectalizable)this.target;
  +    }
   }
  
  
  
  1.2       +6 -15     cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/event/impl/AbstractActionEvent.java
  
  Index: AbstractActionEvent.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/event/impl/AbstractActionEvent.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- AbstractActionEvent.java	7 May 2003 06:22:23 -0000	1.1
  +++ AbstractActionEvent.java	26 May 2003 12:49:13 -0000	1.2
  @@ -53,7 +53,8 @@
   import org.apache.cocoon.portal.event.ActionEvent;
   
   /**
  - *
  + * This event is performed on a target
  + * 
    * @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>
    * 
  @@ -61,27 +62,17 @@
    */
   public abstract class AbstractActionEvent implements ActionEvent {
   
  -    final protected Object target;
  -    
  -    final protected int action;
  +    protected Object target;
       
  -    public AbstractActionEvent(Object target, int action) {
  +    public AbstractActionEvent(Object target) {
           this.target = target;
  -        this.action = action;
       }
       
       /**
  -     * @return int
  -     */
  -    public int getAction() {
  -        return action;
  -    }
  -
  -    /**
        * @return Object
        */
       public Object getTarget() {
  -        return target;
  +        return this.target;
       }
   
   }
  
  
  
  1.2       +1 -5      cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/event/impl/ChangeCopletInstanceAspectDataEvent.java
  
  Index: ChangeCopletInstanceAspectDataEvent.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/event/impl/ChangeCopletInstanceAspectDataEvent.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ChangeCopletInstanceAspectDataEvent.java	26 May 2003 10:34:52 -0000	1.1
  +++ ChangeCopletInstanceAspectDataEvent.java	26 May 2003 12:49:13 -0000	1.2
  @@ -68,8 +68,4 @@
           super( target, aspectName, data );
       }
   
  -    public CopletInstanceData getCopletInstanceData() {
  -        return (CopletInstanceData)this.getTarget();
  -    }
  -
   }
  
  
  
  1.2       +3 -3      cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/event/impl/LayoutRemoveEvent.java
  
  Index: LayoutRemoveEvent.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/event/impl/LayoutRemoveEvent.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- LayoutRemoveEvent.java	7 May 2003 06:22:23 -0000	1.1
  +++ LayoutRemoveEvent.java	26 May 2003 12:49:13 -0000	1.2
  @@ -67,8 +67,8 @@
        * @param target
        * @param action
        */
  -    public LayoutRemoveEvent(Object target, int action) {
  -        super(target, action);
  +    public LayoutRemoveEvent(Object target) {
  +        super(target);
       }
   
   }
  
  
  
  1.2       +8 -5      cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/event/impl/LinkEvent.java
  
  Index: LinkEvent.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/event/impl/LinkEvent.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- LinkEvent.java	8 May 2003 11:54:00 -0000	1.1
  +++ LinkEvent.java	26 May 2003 12:49:13 -0000	1.2
  @@ -50,7 +50,8 @@
   */
   package org.apache.cocoon.portal.event.impl;
   
  -import org.apache.cocoon.portal.event.Event;
  +import org.apache.cocoon.portal.coplet.CopletInstanceData;
  +import org.apache.cocoon.portal.event.CopletInstanceEvent;
   
   /**
    * This class realizes a link event created by the EventLinkTransformer.
  @@ -60,17 +61,19 @@
    * @version CVS $Id$
    */
   public class LinkEvent
  -implements Event {
  +extends AbstractActionEvent
  +implements CopletInstanceEvent {
       
       /**
        * The link to be handled by this event.
        */
  -    private String link;
  +    protected String link;
       
       /**
        * Creates a new LinkEvent.
        */
  -    public LinkEvent(String link) {
  +    public LinkEvent(CopletInstanceData target, String link) {
  +        super(target);
           this.link = link;
       }
       
  
  
  
  1.8       +1 -3      cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/event/impl/DefaultEventManager.java
  
  Index: DefaultEventManager.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/event/impl/DefaultEventManager.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- DefaultEventManager.java	26 May 2003 09:53:00 -0000	1.7
  +++ DefaultEventManager.java	26 May 2003 12:49:13 -0000	1.8
  @@ -80,7 +80,6 @@
   import org.apache.cocoon.portal.event.Subscriber;
   import org.apache.cocoon.portal.event.aspect.EventAspect;
   import org.apache.cocoon.portal.event.subscriber.impl.DefaultChangeAspectDataEventSubscriber;
  -import org.apache.cocoon.portal.event.subscriber.impl.DefaultLayoutEventSubscriber;
   import org.apache.cocoon.portal.event.subscriber.impl.SizingEventSubscriber;
   
   /**
  @@ -155,7 +154,6 @@
           }
   
           // FIXME (CZ,HIGH) : Make this configurable
  -        this.subscribe(new DefaultLayoutEventSubscriber(this.manager));
           this.subscribe(new DefaultChangeAspectDataEventSubscriber(this.manager));
           this.subscribe(new SizingEventSubscriber(this.manager));
       }
  
  
  
  1.3       +23 -3     cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/layout/renderer/aspect/impl/RemovableAspect.java
  
  Index: RemovableAspect.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/layout/renderer/aspect/impl/RemovableAspect.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- RemovableAspect.java	22 May 2003 12:32:46 -0000	1.2
  +++ RemovableAspect.java	26 May 2003 12:49:13 -0000	1.3
  @@ -52,6 +52,7 @@
   
   import org.apache.cocoon.portal.PortalService;
   import org.apache.cocoon.portal.coplet.CopletInstanceData;
  +import org.apache.cocoon.portal.event.Event;
   import org.apache.cocoon.portal.event.impl.LayoutRemoveEvent;
   import org.apache.cocoon.portal.layout.Layout;
   import org.apache.cocoon.portal.layout.impl.CopletLayout;
  @@ -67,7 +68,8 @@
    * 
    * @version CVS $Id$
    */
  -public class RemovableAspect extends AbstractAspect {
  +public class RemovableAspect 
  +    extends AbstractActionAspect {
   
   	/* (non-Javadoc)
   	 * @see org.apache.cocoon.portal.layout.renderer.RendererAspect#toSAX(org.apache.cocoon.portal.layout.renderer.RendererAspectContext,
org.apache.cocoon.portal.layout.Layout, org.apache.cocoon.portal.PortalService, org.xml.sax.ContentHandler)
  @@ -82,10 +84,28 @@
   
           Boolean mandatory = (Boolean)cid.getCopletData().getAspectData("mandatory");
           if ( !mandatory.booleanValue() ) {
  -            LayoutRemoveEvent lre = new LayoutRemoveEvent(layout, 0);
  +            LayoutRemoveEvent lre = new LayoutRemoveEvent(layout);
               XMLUtils.createElement(handler, "remove-uri", service.getLinkService().getLinkURI(lre));
           }
           context.invokeNext(layout, service, handler);
   	}
   
  +    /* (non-Javadoc)
  +     * @see org.apache.cocoon.portal.event.Subscriber#getEventType()
  +     */
  +    public Class getEventType() {
  +        return LayoutRemoveEvent.class;
  +    }
  +
  +    /* (non-Javadoc)
  +     * @see org.apache.cocoon.portal.event.Subscriber#inform(org.apache.cocoon.portal.event.Event)
  +     */
  +    public void inform(Event e) {
  +        // TODO - place this subscriber at a more strategic place
  +        // TODO - if this is a coplet layout remove coplet instance data
  +        // TODO - if this is a composite layout, recursive remove
  +        LayoutRemoveEvent event = (LayoutRemoveEvent)e;
  +        Layout layout = (Layout)event.getTarget();
  +        layout.getParent().getParent().removeItem(layout.getParent());
  +    }
   }
  
  
  
  1.1                  cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/layout/renderer/aspect/impl/AbstractActionAspect.java
  
  Index: AbstractActionAspect.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, are permitted provided that the following conditions are met:
  
   1. Redistributions of  source code must  retain the above copyright  notice,
      this list of conditions and the following disclaimer.
  
   2. Redistributions in binary form must reproduce the above copyright notice,
      this list of conditions and the following disclaimer in the documentation
      and/or other materials provided with the distribution.
  
   3. The end-user documentation included with the redistribution, if any, must
      include  the following  acknowledgment:  "This product includes  software
      developed  by the  Apache Software Foundation  (http://www.apache.org/)."
      Alternately, this  acknowledgment may  appear in the software itself,  if
      and wherever such third-party acknowledgments normally appear.
  
   4. The names "Apache Cocoon" and  "Apache Software Foundation" must  not  be
      used to  endorse or promote  products derived from  this software without
      prior written permission. For written permission, please contact
      apache@apache.org.
  
   5. Products  derived from this software may not  be called "Apache", nor may
      "Apache" appear  in their name,  without prior written permission  of the
      Apache Software Foundation.
  
   THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
   INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
   FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
   APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
   INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
   DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
   OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
   ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
   (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
   THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  
   This software  consists of voluntary contributions made  by many individuals
   on  behalf of the Apache Software  Foundation and was  originally created by
   Stefano Mazzocchi  <stefano@apache.org>. For more  information on the Apache
   Software Foundation, please see <http://www.apache.org/>.
  
  */
  package org.apache.cocoon.portal.layout.renderer.aspect.impl;
  
  import org.apache.avalon.framework.activity.Disposable;
  import org.apache.avalon.framework.activity.Initializable;
  import org.apache.cocoon.portal.event.EventManager;
  import org.apache.cocoon.portal.event.Filter;
  import org.apache.cocoon.portal.event.Subscriber;
  
  /**
   * This aspect creates an event and subscribes to it as well
   * 
   * @author <a href="mailto:cziegeler@s-und-n.de">Carsten Ziegeler</a>
   * 
   * @version CVS $Id: AbstractActionAspect.java,v 1.1 2003/05/26 12:49:13 cziegeler Exp $
   */
  public abstract class AbstractActionAspect
      extends AbstractAspect
      implements Subscriber, Disposable, Initializable {
  
      /* (non-Javadoc)
       * @see org.apache.cocoon.portal.event.Subscriber#getFilter()
       */
      public Filter getFilter() {
          return null;
      }
  
      /* (non-Javadoc)
       * @see org.apache.avalon.framework.activity.Disposable#dispose()
       */
      public void dispose() {
          if ( this.manager != null ) {
              EventManager eventManager = null;
              try { 
                  eventManager = (EventManager)this.manager.lookup(EventManager.ROLE);
                  eventManager.getRegister().unsubscribe( this );
              } catch (Exception ignore) {
              } finally {
                  this.manager.release( eventManager ); 
              }
              
              this.manager = null;
          }
      }
  
      /* (non-Javadoc)
       * @see org.apache.avalon.framework.activity.Initializable#initialize()
       */
      public void initialize() throws Exception {
          EventManager eventManager = null;
          try { 
              eventManager = (EventManager)this.manager.lookup(EventManager.ROLE);
              eventManager.getRegister().subscribe( this );
          } finally {
              this.manager.release( eventManager );
          }
      }
  
  }
  
  
  
  1.2       +11 -62    cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/transformation/CopletTransformer.java
  
  Index: CopletTransformer.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/transformation/CopletTransformer.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- CopletTransformer.java	8 May 2003 11:54:00 -0000	1.1
  +++ CopletTransformer.java	26 May 2003 12:49:13 -0000	1.2
  @@ -51,16 +51,9 @@
   package org.apache.cocoon.portal.transformation;
   
   import java.io.IOException;
  -import java.util.Map;
   
  -import org.apache.avalon.framework.component.ComponentException;
  -import org.apache.avalon.framework.parameters.ParameterException;
   import org.apache.cocoon.ProcessingException;
  -import org.apache.cocoon.environment.ObjectModelHelper;
  -import org.apache.cocoon.portal.Constants;
  -import org.apache.cocoon.portal.PortalService;
  -import org.apache.cocoon.portal.profile.ProfileManager;
  -import org.apache.cocoon.transformation.AbstractSAXTransformer;
  +import org.apache.cocoon.portal.coplet.CopletInstanceData;
   import org.apache.commons.jxpath.JXPathContext;
   import org.xml.sax.Attributes;
   import org.xml.sax.SAXException;
  @@ -72,7 +65,7 @@
    * @version CVS $Id$
    */
   public class CopletTransformer 
  -extends AbstractSAXTransformer {
  +extends AbstractCopletTransformer {
   
       /**
        * The namespace URI to listen for.
  @@ -89,16 +82,7 @@
        */
       public static final String SELECT_ATTR = "select";
   
  -    /**
  -     * Parameter name.
  -     */
  -    public static final String COPLET_ID_PARAM = "copletId";
  -    
  -    /**
  -     * Parameter name.
  -     */
  -    public static final String PORTAL_NAME_PARAM = "portalName";
  -    
  +        
       /**
        * Creates new CopletTransformer.
        */
  @@ -117,50 +101,15 @@
                   throw new ProcessingException("Attribute "+SELECT_ATTR+" must be spcified.");
               }
                   
  -            ProfileManager profileManager = null;
  -            try {
  -                profileManager = (ProfileManager)this.manager.lookup(ProfileManager.ROLE);
  -
  -                // determine coplet id
  -                String copletId = null;            
  -                Map context = (Map)objectModel.get(ObjectModelHelper.PARENT_CONTEXT);
  -                if (context != null) {
  -                    copletId = (String)context.get(Constants.COPLET_ID_KEY);
  -                    if (copletId == null) {
  -                        throw new ProcessingException("copletId must be passed as parameter
or in the object model within the parent context.");
  -                    }
  -                } else {
  -					try {
  -						copletId = this.parameters.getParameter(COPLET_ID_PARAM);
  -						
  -						// set portal name
  -						PortalService portalService = null;
  -						try {
  -						    portalService = (PortalService)this.manager.lookup(PortalService.ROLE);
  -						    portalService.setPortalName(this.parameters.getParameter(PORTAL_NAME_PARAM));
  -						} finally {
  -						    this.manager.release(portalService);
  -						}
  -					} catch (ParameterException e) {
  -                        throw new ProcessingException("copletId and portalName must be
passed as parameter or in the object model within the parent context.");
  -					}
  -                }
  -
  -                JXPathContext jxpathContext = JXPathContext.newContext(profileManager.getCopletInstanceData(copletId));
  -                Object object = jxpathContext.getValue(expression);
  -                
  -                if (object == null) {
  -                    throw new ProcessingException("Could not find value for expression
"+expression);
  -                }
  +            CopletInstanceData cid = this.getCopletInstanceData();
  +            
  +            JXPathContext jxpathContext = JXPathContext.newContext( cid );
  +            Object object = jxpathContext.getValue(expression);
                   
  -                String value = object.toString();
  -                super.characters(value.toCharArray(), 0, value.length());
  -            } catch (ComponentException e) {
  -                throw new ProcessingException("Error getting profile manager.", e);
  -            } finally {
  -                this.manager.release(profileManager);
  +            if (object == null) {
  +                throw new ProcessingException("Could not find value for expression "+expression);
               }
  -            
  +                
           } else {
               super.startTransformingElement(uri, name, raw, attr);
           }
  
  
  
  1.2       +7 -5      cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/transformation/EventLinkTransformer.java
  
  Index: EventLinkTransformer.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/transformation/EventLinkTransformer.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- EventLinkTransformer.java	8 May 2003 11:54:00 -0000	1.1
  +++ EventLinkTransformer.java	26 May 2003 12:49:13 -0000	1.2
  @@ -54,8 +54,8 @@
   
   import org.apache.avalon.framework.component.ComponentException;
   import org.apache.cocoon.portal.LinkService;
  +import org.apache.cocoon.portal.coplet.CopletInstanceData;
   import org.apache.cocoon.portal.event.impl.LinkEvent;
  -import org.apache.cocoon.transformation.AbstractSAXTransformer;
   import org.w3c.dom.DocumentFragment;
   import org.xml.sax.Attributes;
   import org.xml.sax.SAXException;
  @@ -71,7 +71,7 @@
    * @version CVS $Id$
    */
   public class EventLinkTransformer 
  -extends AbstractSAXTransformer {
  +extends AbstractCopletTransformer {
       
       /**
        * The namespace URI to listen for.
  @@ -186,12 +186,13 @@
   
                       // if attribute found that contains a link
                       if (link != null) {
  +                        CopletInstanceData cid = this.getCopletInstanceData();        
              
                           LinkService linkService = null;
                           try {
                               linkService = (LinkService)this.manager.lookup(LinkService.ROLE);
           
                               // create event link
  -                            LinkEvent event = new LinkEvent(link);
  +                            LinkEvent event = new LinkEvent(cid, link);
                               String eventLink = linkService.getLinkURI(event);
           
                               // insert event link
  @@ -211,12 +212,13 @@
                   if (this.elementName != null && name.equals(this.elementName))
{
                       String link = this.endTextRecording();
   
  +                    CopletInstanceData cid = this.getCopletInstanceData();            
          
                       LinkService linkService = null;
                       try {
                           linkService = (LinkService)this.manager.lookup(LinkService.ROLE);
           
                           // create event link
  -                        LinkEvent event = new LinkEvent(link);
  +                        LinkEvent event = new LinkEvent(cid, link);
                           eventLink = linkService.getLinkURI(event);
                       } catch (ComponentException e) {
                           throw new SAXException(e);
  
  
  
  1.1                  cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/transformation/AbstractCopletTransformer.java
  
  Index: AbstractCopletTransformer.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, are permitted provided that the following conditions are met:
  
   1. Redistributions of  source code must  retain the above copyright  notice,
      this list of conditions and the following disclaimer.
  
   2. Redistributions in binary form must reproduce the above copyright notice,
      this list of conditions and the following disclaimer in the documentation
      and/or other materials provided with the distribution.
  
   3. The end-user documentation included with the redistribution, if any, must
      include  the following  acknowledgment:  "This product includes  software
      developed  by the  Apache Software Foundation  (http://www.apache.org/)."
      Alternately, this  acknowledgment may  appear in the software itself,  if
      and wherever such third-party acknowledgments normally appear.
  
   4. The names "Apache Cocoon" and  "Apache Software Foundation" must  not  be
      used to  endorse or promote  products derived from  this software without
      prior written permission. For written permission, please contact
      apache@apache.org.
  
   5. Products  derived from this software may not  be called "Apache", nor may
      "Apache" appear  in their name,  without prior written permission  of the
      Apache Software Foundation.
  
   THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
   INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
   FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
   APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
   INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
   DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
   OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
   ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
   (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
   THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  
   This software  consists of voluntary contributions made  by many individuals
   on  behalf of the Apache Software  Foundation and was  originally created by
   Stefano Mazzocchi  <stefano@apache.org>. For more  information on the Apache
   Software Foundation, please see <http://www.apache.org/>.
  
  */
  package org.apache.cocoon.portal.transformation;
  
  import java.util.Map;
  
  import org.apache.avalon.framework.component.ComponentException;
  import org.apache.avalon.framework.parameters.ParameterException;
  import org.apache.cocoon.environment.ObjectModelHelper;
  import org.apache.cocoon.portal.Constants;
  import org.apache.cocoon.portal.PortalService;
  import org.apache.cocoon.portal.coplet.CopletInstanceData;
  import org.apache.cocoon.portal.profile.ProfileManager;
  import org.apache.cocoon.transformation.AbstractSAXTransformer;
  import org.xml.sax.SAXException;
  
  /**
   * Abstract transformer implementation
   *
   * @author <a href="mailto:cziegeler@s-und-n.de">Carsten Ziegeler</a>
   * @version CVS $Id: AbstractCopletTransformer.java,v 1.1 2003/05/26 12:49:13 cziegeler
Exp $
   */
  public abstract class AbstractCopletTransformer 
  extends AbstractSAXTransformer {
  
      /**
       * Parameter name.
       */
      public static final String COPLET_ID_PARAM = "copletId";
  
      /**
       * Parameter name.
       */
      public static final String PORTAL_NAME_PARAM = "portalName";
  
      protected CopletInstanceData getCopletInstanceData() 
      throws SAXException {
          ProfileManager profileManager = null;
          try {
              profileManager = (ProfileManager)this.manager.lookup(ProfileManager.ROLE);
  
              // determine coplet id
              String copletId = null;            
              Map context = (Map)objectModel.get(ObjectModelHelper.PARENT_CONTEXT);
              if (context != null) {
                  copletId = (String)context.get(Constants.COPLET_ID_KEY);
              } else {
                  try {
                      copletId = this.parameters.getParameter(COPLET_ID_PARAM);
                          
                      // set portal name
                      PortalService portalService = null;
                      try {
                          portalService = (PortalService)this.manager.lookup(PortalService.ROLE);
                          portalService.setPortalName(this.parameters.getParameter(PORTAL_NAME_PARAM));
                      } finally {
                          this.manager.release(portalService);
                      }
                  } catch (ParameterException e) {
                      throw new SAXException("copletId and portalName must be passed as parameter
or in the object model within the parent context.");
                  }
              }
              if (copletId == null) {
                  throw new SAXException("copletId must be passed as parameter or in the object
model within the parent context.");
              }
  
  
              CopletInstanceData object = profileManager.getCopletInstanceData( copletId );
                  
              if (object == null) {
                  throw new SAXException("Could not find coplet instance data for " + copletId);
              }
                  
              return object;
          } catch (ComponentException e) {
              throw new SAXException("Error getting profile manager.", e);
          } finally {
              this.manager.release(profileManager);
          }
      }
  }
  
  
  
  1.2       +2 -2      cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/event/subscriber/impl/DefaultChangeAspectDataEventSubscriber.java
  
  Index: DefaultChangeAspectDataEventSubscriber.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/event/subscriber/impl/DefaultChangeAspectDataEventSubscriber.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DefaultChangeAspectDataEventSubscriber.java	23 May 2003 14:20:09 -0000	1.1
  +++ DefaultChangeAspectDataEventSubscriber.java	26 May 2003 12:49:13 -0000	1.2
  @@ -91,7 +91,7 @@
        */
       public void inform(Event e) {
           final ChangeAspectDataEvent event = (ChangeAspectDataEvent)e;
  -        final Aspectalizable target = event.getTarget();
  +        final Aspectalizable target = event.getAspectalizable();
           target.setAspectData(event.getAspectName(), event.getData());
       }
   
  
  
  
  1.2       +3 -4      cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/event/ActionEvent.java
  
  Index: ActionEvent.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/event/ActionEvent.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ActionEvent.java	7 May 2003 06:22:26 -0000	1.1
  +++ ActionEvent.java	26 May 2003 12:49:13 -0000	1.2
  @@ -51,7 +51,8 @@
   package org.apache.cocoon.portal.event;
   
   /**
  - *
  + * This event is performed "on" a target
  + * 
    * @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>
    * 
  @@ -60,7 +61,5 @@
   public interface ActionEvent extends Event {
   
       Object getTarget();
  -    
  -    int getAction();
       
   }
  
  
  
  1.2       +2 -5      cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/event/CopletInstanceEvent.java
  
  Index: CopletInstanceEvent.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/event/CopletInstanceEvent.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- CopletInstanceEvent.java	26 May 2003 10:34:53 -0000	1.1
  +++ CopletInstanceEvent.java	26 May 2003 12:49:13 -0000	1.2
  @@ -50,7 +50,6 @@
   */
   package org.apache.cocoon.portal.event;
   
  -import org.apache.cocoon.portal.coplet.CopletInstanceData;
   
   /**
    * This interface marks an event as an event for a coplet instance.
  @@ -60,8 +59,6 @@
    * @version CVS $Id$
    */
   public interface CopletInstanceEvent 
  -    extends Event {
  +    extends ActionEvent {
           
  -    CopletInstanceData getCopletInstanceData();
  -
   }
  
  
  
  1.2       +4 -2      cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/event/LayoutEvent.java
  
  Index: LayoutEvent.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/event/LayoutEvent.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- LayoutEvent.java	7 May 2003 06:22:26 -0000	1.1
  +++ LayoutEvent.java	26 May 2003 12:49:14 -0000	1.2
  @@ -51,7 +51,9 @@
   package org.apache.cocoon.portal.event;
   
   /**
  - *
  + * This interface marks an {@link ActionEvent} as targetted at a {@link Layout}
  + * object
  + * 
    * @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>
    * 
  
  
  
  1.9       +2 -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.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- URICopletAdapter.java	26 May 2003 10:34:52 -0000	1.8
  +++ URICopletAdapter.java	26 May 2003 12:49:14 -0000	1.9
  @@ -194,7 +194,7 @@
               if ( list == null ) {
                   list = new ArrayList();
               }
  -            list.add(event.getCopletInstanceData());
  +            list.add(event.getTarget());
               service.setTemporaryAttribute(URICopletAdapter.class.getName(), list);
           } catch (ComponentException ignore ) {            
           } finally {
  
  
  

Mime
View raw message