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/impl DefaultLinkService.java
Date Sat, 28 Feb 2004 17:26:28 GMT
cziegeler    2004/02/28 09:26:28

  Modified:    src/blocks/portal/java/org/apache/cocoon/portal/transformation
                        CopletTransformer.java
                        AbstractCopletTransformer.java
               src/blocks/portal/java/org/apache/cocoon/portal
                        LinkService.java
               src/blocks/portal/java/org/apache/cocoon/portal/impl
                        DefaultLinkService.java
  Log:
  Fix problems when an event for a non-existent coplet is tried to be created
  
  Revision  Changes    Path
  1.15      +11 -5     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.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- CopletTransformer.java	13 Feb 2004 11:50:30 -0000	1.14
  +++ CopletTransformer.java	28 Feb 2004 17:26:27 -0000	1.15
  @@ -197,20 +197,26 @@
                       newAttrs.removeAttribute("path");
                       newAttrs.removeAttribute("value");
                       
  -                    JXPathEvent event;
  +                    JXPathEvent event = null;
                       if ( attr.getValue("layout") != null ) {
                           newAttrs.removeAttribute("layout");
                           final String layoutId = attr.getValue("layout");
                           Object layout = portalService.getComponentManager().getProfileManager().getPortalLayout(null,
layoutId);
  -                        event = new JXPathEvent(layout, path, value);
  +                        if ( layout != null ) {
  +                            event = new JXPathEvent(layout, path, value);
  +                        }
                       } else {
                           String copletId = attr.getValue("coplet");
                           newAttrs.removeAttribute("coplet");
                           final CopletInstanceData cid = this.getCopletInstanceData(copletId);
  -                        event = new CopletJXPathEvent(cid, path, value);
  +                        if ( cid != null ) {
  +                            event = new CopletJXPathEvent(cid, path, value);
  +                        }
                       }
                       if ( this.insideLinks ) {
  -                        this.collectedEvents.add(event);
  +                        if ( event != null ) {
  +                            this.collectedEvents.add(event);
  +                        }
                       } else {
                           final String href = linkService.getLinkURI(event);
                           this.output(href, format, newAttrs );
  
  
  
  1.7       +18 -6     cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/transformation/AbstractCopletTransformer.java
  
  Index: AbstractCopletTransformer.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/transformation/AbstractCopletTransformer.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- AbstractCopletTransformer.java	12 Feb 2004 09:32:37 -0000	1.6
  +++ AbstractCopletTransformer.java	28 Feb 2004 17:26:27 -0000	1.7
  @@ -91,11 +91,27 @@
        */
       public static final String PORTAL_NAME_PARAM = "portalName";
   
  +    /**
  +     * Try to get the coplet instance data belonging to the current request
  +     * @return The coplet instance data
  +     * @throws SAXException If an errors occurs or the instance data is not available
  +     */
       protected CopletInstanceData getCopletInstanceData() 
       throws SAXException {
  -        return this.getCopletInstanceData(null);
  +        CopletInstanceData cid = this.getCopletInstanceData(null);
  +        if ( cid == null ) {
  +            throw new SAXException("Could not find coplet instance data for the current
pipeline.");
  +        }
  +        return cid;
       }
       
  +    /**
  +     * Try to get the coplet instance data with the given id
  +     * @param copletId  The id of the coplet instance or null if this transformer
  +     *                   is used inside a coplet pipeline
  +     * @return The coplet instance data or null
  +     * @throws SAXException If an error occurs
  +     */
       protected CopletInstanceData getCopletInstanceData(String copletId) 
       throws SAXException {
           PortalService portalService = null;
  @@ -133,10 +149,6 @@
   
   
               CopletInstanceData object = portalService.getComponentManager().getProfileManager().getCopletInstanceData(
copletId );
  -                
  -            if (object == null) {
  -                throw new SAXException("Could not find coplet instance data for " + copletId);
  -            }
                   
               return object;
           } catch (ServiceException e) {
  
  
  
  1.4       +2 -2      cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/LinkService.java
  
  Index: LinkService.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/LinkService.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- LinkService.java	8 Dec 2003 13:47:50 -0000	1.3
  +++ LinkService.java	28 Feb 2004 17:26:28 -0000	1.4
  @@ -70,7 +70,7 @@
       
       /**
        * Get the uri for this coplet containing the additional event
  -     * @param event The event to add
  +     * @param event The event to add (null is also allowed for convenience)
        * @return A URI
        */
       String getLinkURI(Event event);
  
  
  
  1.11      +10 -1     cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/impl/DefaultLinkService.java
  
  Index: DefaultLinkService.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/impl/DefaultLinkService.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- DefaultLinkService.java	11 Dec 2003 13:31:55 -0000	1.10
  +++ DefaultLinkService.java	28 Feb 2004 17:26:28 -0000	1.11
  @@ -136,6 +136,9 @@
        * @see org.apache.cocoon.portal.LinkService#getLinkURI(org.apache.cocoon.portal.event.Event)
        */
       public String getLinkURI(Event event) {
  +        if ( event == null ) {
  +            return this.getRefreshLinkURI();   
  +        }
           final Info info = this.getInfo();
           final StringBuffer buffer = new StringBuffer(info.linkBase.toString());
           boolean hasParams = info.hasParameters;
  @@ -189,6 +192,9 @@
        * @see org.apache.cocoon.portal.LinkService#getLinkURI(java.util.List)
        */
       public String getLinkURI(List events) {
  +        if ( events == null || events.size() == 0) {
  +            return this.getRefreshLinkURI();   
  +        }
           final Info info = this.getInfo();
           boolean hasParams = info.hasParameters;
           final StringBuffer buffer = new StringBuffer(info.linkBase.toString());
  @@ -232,6 +238,9 @@
        * @see org.apache.cocoon.portal.LinkService#addEventToLink(org.apache.cocoon.portal.event.Event)
        */
       public void addEventToLink(Event event) {
  +        if ( event == null ) {
  +            return;   
  +        }
           String parameterName = DEFAULT_REQUEST_EVENT_PARAMETER_NAME;
           if (event instanceof RequestEvent ) {
               final String eventParName = ((RequestEvent)event).getRequestParameterName();
  
  
  

Mime
View raw message