Coverage report

  %line %branch
org.apache.jetspeed.layout.impl.GetFolderListAction
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.Map;
 20  
 import java.util.StringTokenizer;
 21  
 
 22  
 import org.apache.commons.logging.Log;
 23  
 import org.apache.commons.logging.LogFactory;
 24  
 import org.apache.jetspeed.JetspeedActions;
 25  
 import org.apache.jetspeed.ajax.AjaxAction;
 26  
 import org.apache.jetspeed.ajax.AjaxBuilder;
 27  
 import org.apache.jetspeed.layout.PortletActionSecurityBehavior;
 28  
 import org.apache.jetspeed.om.folder.Folder;
 29  
 import org.apache.jetspeed.page.PageManager;
 30  
 import org.apache.jetspeed.request.RequestContext;
 31  
 
 32  
 /**
 33  
  * Get the immediate contents of a folder in JSON format 
 34  
  *
 35  
  * AJAX Parameters: 
 36  
  *    folder: full path to the folder 
 37  
  *    
 38  
  * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
 39  
  * @version $Id: $
 40  
  */
 41  
 public class GetFolderListAction 
 42  
     extends BaseGetResourceAction 
 43  
     implements AjaxAction, AjaxBuilder, Constants
 44  
 {
 45  0
     protected Log log = LogFactory.getLog(GetThemesAction.class);
 46  
     
 47  
     public GetFolderListAction(String template, 
 48  
             String errorTemplate,
 49  
             PageManager pageManager,
 50  
             PortletActionSecurityBehavior securityBehavior)
 51  
     {
 52  0
         super(template, errorTemplate, pageManager, securityBehavior);        
 53  0
     }
 54  
 
 55  
     public boolean run(RequestContext requestContext, Map resultMap)
 56  
     {
 57  0
         boolean success = true;
 58  0
         String status = "success";
 59  
         try
 60  
         {
 61  0
             resultMap.put(ACTION, "getfolderlist");
 62  0
             if (false == checkAccess(requestContext, JetspeedActions.VIEW))
 63  
             {
 64  0
                     success = false;
 65  0
                     resultMap.put(REASON, "Insufficient access to get folderlist");
 66  0
                     return success;
 67  
             }                     
 68  0
             String data = getActionParameter(requestContext, "data");
 69  0
             StringTokenizer tokenizer = new StringTokenizer(data, "[{:\"");
 70  0
             String folderName = null;            
 71  0
             while (tokenizer.hasMoreTokens())
 72  
             {
 73  0
                 String token = tokenizer.nextToken();
 74  0
                 if (token.equals("widgetId"))
 75  
                 {
 76  0
                     folderName = tokenizer.nextToken();
 77  0
                     break;
 78  
                 }
 79  0
             }
 80  0
             String format = getActionParameter(requestContext, FORMAT);
 81  0
             if (format == null)
 82  0
                 format = "json";
 83  0
             if (folderName == null)
 84  
             {
 85  0
                 success = false;
 86  0
                 resultMap.put(REASON, "Folder name not found.");
 87  0
                 return success;                
 88  
             }
 89  0
             resultMap.put(FORMAT, format);
 90  0
             Folder folder = pageManager.getFolder(folderName);
 91  0
             resultMap.put(FOLDER, folder);
 92  0
             resultMap.put("folders", folder.getFolders().iterator());
 93  0
             resultMap.put("pages", folder.getPages().iterator());
 94  0
             resultMap.put("links", folder.getLinks().iterator());
 95  0
             resultMap.put(STATUS, status);            
 96  
         } 
 97  0
         catch (Exception e)
 98  
         {
 99  
             // Log the exception
 100  0
             log.error("exception while getting theme info", e);
 101  
             // Return a failure indicator
 102  0
             success = false;
 103  0
         }
 104  
 
 105  0
         return success;
 106  
     }
 107  
     
 108  
     
 109  
 }

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