Coverage report

  %line %branch
org.apache.jetspeed.layout.impl.GetPortletActionsAction
0% 
0% 

 1  
 /*
 2  
  * Licensed to the Apache Software Foundation (ASF) under one or more
 3  
  * contributor license agreements.  See the NOTICE file distributed with
 4  
  * this work for additional information regarding copyright ownership.
 5  
  * The ASF licenses this file to You under the Apache License, Version 2.0
 6  
  * (the "License"); you may not use this file except in compliance with
 7  
  * the License.  You may obtain a copy of the License at
 8  
  * 
 9  
  *      http://www.apache.org/licenses/LICENSE-2.0
 10  
  * 
 11  
  * Unless required by applicable law or agreed to in writing, software
 12  
  * distributed under the License is distributed on an "AS IS" BASIS,
 13  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 14  
  * See the License for the specific language governing permissions and
 15  
  * limitations under the License.
 16  
  */
 17  
 package org.apache.jetspeed.layout.impl;
 18  
 
 19  
 import java.util.ArrayList;
 20  
 import java.util.Map;
 21  
 
 22  
 import org.apache.commons.logging.Log;
 23  
 import org.apache.commons.logging.LogFactory;
 24  
 import org.apache.jetspeed.ajax.AJAXException;
 25  
 import org.apache.jetspeed.ajax.AjaxAction;
 26  
 import org.apache.jetspeed.ajax.AjaxBuilder;
 27  
 import org.apache.jetspeed.decoration.DecorationValve;
 28  
 import org.apache.jetspeed.layout.PortletActionSecurityBehavior;
 29  
 import org.apache.jetspeed.om.page.ContentFragment;
 30  
 import org.apache.jetspeed.om.page.ContentPage;
 31  
 import org.apache.jetspeed.om.page.Fragment;
 32  
 import org.apache.jetspeed.page.PageManager;
 33  
 import org.apache.jetspeed.request.RequestContext;
 34  
 
 35  
 /**
 36  
  * Get Portlet Actions retrieves the current set of valid actions for one or more portlet windows
 37  
  *
 38  
  * AJAX Parameters: 
 39  
  *    id = the fragment id of the portlet for which to retrieve the action list
 40  
  *         multiple id parameters are supported
 41  
  *    page = (implied in the URL)
 42  
  *    
 43  
  * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
 44  
  * @version $Id: $
 45  
  */
 46  
 public class GetPortletActionsAction
 47  
     extends BasePortletAction 
 48  
     implements AjaxAction, AjaxBuilder, Constants
 49  
 {
 50  0
     protected static final Log log = LogFactory.getLog(GetPortletActionsAction.class);
 51  
     protected String action;
 52  
     private DecorationValve decorationValve;
 53  
     
 54  
     public GetPortletActionsAction(String template,
 55  
                                    String errorTemplate,
 56  
                                    String action,
 57  
                                    DecorationValve decorationValve)            
 58  
     throws AJAXException
 59  
     {
 60  0
         this(template, errorTemplate, action, decorationValve, null, class="keyword">null);
 61  0
     }
 62  
     
 63  
     public GetPortletActionsAction(String template,
 64  
                                    String errorTemplate,
 65  
                                    String action,
 66  
                                    DecorationValve decorationValve,
 67  
                                    PageManager pageManager,
 68  
                                    PortletActionSecurityBehavior securityBehavior)
 69  
     throws AJAXException
 70  
     {
 71  0
         super(template, errorTemplate, pageManager, securityBehavior);
 72  0
         this.action = action;
 73  0
         this.decorationValve = decorationValve;
 74  0
     }
 75  
 
 76  
     public boolean runBatch(RequestContext requestContext, Map resultMap) throws AJAXException
 77  
     {
 78  0
         return runAction(requestContext, resultMap, true);
 79  
     }    
 80  
     
 81  
     public boolean run(RequestContext requestContext, Map resultMap)
 82  
             throws AJAXException
 83  
     {
 84  0
         return runAction(requestContext, resultMap, false);
 85  
     }
 86  
     
 87  
     public boolean runAction( RequestContext requestContext, Map resultMap, class="keyword">boolean batch )
 88  
     {
 89  0
         boolean success = true;
 90  0
         String status = "success";
 91  
         try
 92  
         {
 93  0
             resultMap.put( ACTION, action );
 94  
             
 95  0
             ContentPage page = requestContext.getPage();
 96  
             
 97  
             // Get the necessary parameters off of the request
 98  0
             ArrayList getActionsForFragments = new ArrayList();
 99  0
             String[] portletIds = requestContext.getRequest().getParameterValues( PORTLETID );
 100  0
             if ( portletIds != null && portletIds.length > 0 ) 
 101  
             {
 102  0
                 for ( int i = 0 ; i < portletIds.length ; i++ )
 103  
                 {
 104  0
                     String portletId = portletIds[ i ];
 105  0
                     ContentFragment fragment = (ContentFragment)page.getFragmentById( portletId );
 106  0
                     if ( fragment == null )
 107  
                     {
 108  0
                         throw new Exception("fragment not found for specified portlet id: " + portletId); 
 109  
                     }
 110  0
                     getActionsForFragments.add( fragment );
 111  
                 }
 112  0
                 getActionsForFragments.add( page.getRootContentFragment() );
 113  
             }
 114  
 
 115  
             // Run the Decoration valve to get actions
 116  0
             decorationValve.initFragments( requestContext, true, getActionsForFragments );
 117  
             
 118  0
             if ( getActionsForFragments.size() > 0 )
 119  
             {
 120  0
                 Fragment rootFragment = (Fragment)getActionsForFragments.remove( getActionsForFragments.size()-1 );
 121  0
                 resultMap.put( PAGE, rootFragment );
 122  
             }
 123  
             
 124  0
             resultMap.put( PORTLETS, getActionsForFragments );
 125  
             
 126  0
             resultMap.put( STATUS, status );
 127  
         } 
 128  0
         catch (Exception e)
 129  
         {
 130  
             // Log the exception
 131  0
             log.error( "exception while getting actions for a fragment", e );
 132  0
             resultMap.put( REASON, e.toString() );
 133  
             // Return a failure indicator
 134  0
             success = false;
 135  0
         }
 136  
 
 137  0
         return success;
 138  
     }
 139  
 }

This report is generated by jcoverage, Maven and Maven JCoverage Plugin.