Coverage report

  %line %branch
org.apache.jetspeed.layout.impl.BasePortletAction
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.Iterator;
 20  
 import java.util.List;
 21  
 import java.util.Map;
 22  
 
 23  
 import org.apache.commons.logging.Log;
 24  
 import org.apache.commons.logging.LogFactory;
 25  
 import org.apache.jetspeed.ajax.AJAXException;
 26  
 import org.apache.jetspeed.ajax.AjaxAction;
 27  
 import org.apache.jetspeed.ajax.AjaxBuilder;
 28  
 import org.apache.jetspeed.layout.PortletActionSecurityBehavior;
 29  
 import org.apache.jetspeed.om.page.Fragment;
 30  
 import org.apache.jetspeed.om.page.Page;
 31  
 import org.apache.jetspeed.page.PageManager;
 32  
 import org.apache.jetspeed.request.RequestContext;
 33  
 
 34  
 /**
 35  
  * Abstract portlet placement action
 36  
  *
 37  
  * @author <a>David Gurney</a>
 38  
  * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
 39  
  * @version $Id: $
 40  
  */
 41  
 public abstract class BasePortletAction 
 42  
     implements AjaxAction, AjaxBuilder, Constants 
 43  
 {
 44  0
     protected static final Log log = LogFactory.getLog(BasePortletAction.class);    
 45  0
 	protected String template = null;
 46  0
     protected PageManager pageManager = null;
 47  0
     protected String errorTemplate = null;
 48  
     protected PortletActionSecurityBehavior securityBehavior;
 49  
     
 50  
     public BasePortletAction(String template, 
 51  
                              String errorTemplate, 
 52  
                              PortletActionSecurityBehavior securityBehavior)
 53  0
     {
 54  0
         this.template = template;
 55  0
         this.errorTemplate = errorTemplate;
 56  0
         this.securityBehavior = securityBehavior;
 57  0
     }
 58  
 
 59  
     public BasePortletAction(String template, 
 60  
             String errorTemplate, 
 61  
             PageManager pageManager)
 62  0
     {
 63  0
         this.template = template;
 64  0
         this.errorTemplate = errorTemplate;
 65  0
         this.pageManager = pageManager;
 66  0
         this.securityBehavior = null;
 67  0
     }
 68  
     
 69  
     public BasePortletAction(String template, 
 70  
                              String errorTemplate, 
 71  
                              PageManager pageManager,
 72  
                              PortletActionSecurityBehavior securityBehavior)
 73  
     {
 74  0
         this(template, errorTemplate, securityBehavior);
 75  0
         this.pageManager = pageManager;
 76  0
     }
 77  
 
 78  
     public boolean buildContext(RequestContext requestContext, Map responseContext)
 79  
     {
 80  0
         return true;
 81  
     }
 82  
 
 83  
     public boolean buildErrorContext(RequestContext requestContext,
 84  
             Map responseContext) 
 85  
     {
 86  0
         responseContext.put(STATUS, "failure");
 87  
 
 88  
         // Check for the case where we don't know basic information
 89  0
         if (responseContext.get(ACTION) == null)
 90  
         {
 91  0
             responseContext.put(ACTION, "unknown");
 92  
         }
 93  
 
 94  0
         if (responseContext.get(PORTLETID) == null)
 95  
         {
 96  0
             responseContext.put(PORTLETID, "unknown");
 97  
         }
 98  
 
 99  0
         return true;
 100  
     }
 101  
 
 102  
     public String getErrorTemplate()
 103  
     {
 104  0
         return errorTemplate;
 105  
     }
 106  
 
 107  
     public String getTemplate()
 108  
     {
 109  0
         return template;
 110  
     }
 111  
 
 112  
     public boolean checkAccess(RequestContext context, String action)
 113  
     {
 114  0
         boolean access = true;
 115  0
         if (null != securityBehavior)
 116  
         {
 117  0
             access = securityBehavior.checkAccess(context, action);
 118  
         }
 119  0
         return access;
 120  
     }
 121  
     
 122  
     public boolean isCreateNewPageOnEditEnabled()
 123  
     {
 124  0
     	if (securityBehavior == null)
 125  0
             return false;
 126  0
     	return securityBehavior.isCreateNewPageOnEditEnabled();
 127  
     }
 128  
     public boolean isPageQualifiedForCreateNewPageOnEdit(RequestContext context)
 129  
     {
 130  0
     	if (securityBehavior == null)
 131  0
             return false;
 132  0
     	return securityBehavior.isPageQualifiedForCreateNewPageOnEdit(context);
 133  
     }
 134  
     public boolean createNewPageOnEdit(RequestContext context)
 135  
     {
 136  0
         if (securityBehavior == null)
 137  0
             return false;
 138  
         
 139  0
         return securityBehavior.createNewPageOnEdit(context);        
 140  
     }
 141  
     
 142  
     public Fragment getFragmentIdFromLocation( int row, class="keyword">int column, Page page )
 143  
     {
 144  0
     	return getFragmentIdFromLocation( row, column, page.getRootFragment() );
 145  
     }
 146  
     public Fragment getFragmentIdFromLocation( int row, class="keyword">int column, Fragment parentFragment )
 147  
     {
 148  0
         Iterator fragments = parentFragment.getFragments().iterator();
 149  0
         while ( fragments.hasNext() )
 150  
         {
 151  0
             Fragment fragment = (Fragment)fragments.next();
 152  0
             if ( fragment.getLayoutColumn() == column && fragment.getLayoutRow() == row )
 153  
             {
 154  0
                 return fragment;
 155  
             }
 156  0
         }
 157  0
         return null;
 158  
     }
 159  
     
 160  
     public boolean runBatch(RequestContext requestContext, Map resultMap) throws AJAXException
 161  
     {
 162  0
         return run(requestContext, resultMap);
 163  
     }
 164  
     
 165  
     public String getActionParameter(RequestContext requestContext, String name)
 166  
     {
 167  0
         String parameter = requestContext.getRequestParameter(name);
 168  0
         if (parameter == null)
 169  
         {
 170  0
             Object o = requestContext.getAttribute(name);
 171  0
             if (o != null)
 172  
             {
 173  0
                 if (o instanceof String)
 174  0
                     return (String)o;
 175  
             }
 176  
         }
 177  0
         return parameter;
 178  
     }
 179  
     
 180  
     public String getNonNullActionParameter(RequestContext requestContext, String name)
 181  
     {
 182  0
         String result = getActionParameter(requestContext, name);
 183  0
         if (result == null)
 184  0
             return "";
 185  0
         return result;
 186  
     }
 187  
     
 188  
     public Fragment getParentFragmentById(String id, Fragment root)
 189  
     {
 190  0
     	return NestedFragmentContext.getParentFragmentById( id, root );
 191  
     }    
 192  
 }

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