Coverage report

  %line %branch
org.apache.jetspeed.util.descriptor.WebApplicationDescriptor
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.util.descriptor;
 18  
 
 19  
 import java.io.Reader;
 20  
 
 21  
 import org.apache.commons.digester.Digester;
 22  
 import org.apache.jetspeed.om.common.servlet.MutableWebApplication;
 23  
 import org.apache.jetspeed.om.servlet.impl.SecurityRoleImpl;
 24  
 import org.apache.jetspeed.om.servlet.impl.WebApplicationDefinitionImpl;
 25  
 import org.apache.jetspeed.tools.pamanager.PortletApplicationException;
 26  
 import org.apache.jetspeed.util.JetspeedLocale;
 27  
 
 28  
 /**
 29  
  * Utilities for manipulating the web.xml deployment descriptor
 30  
  * 
 31  
  * @author <a href="mailto:ate@douma.nu">Ate Douma </a>*
 32  
  * @version $Id: WebDescriptorUtilities.java,v 1.2 2004/05/12 22:25:04 taylor
 33  
  *                Exp $
 34  
  */
 35  
 public class WebApplicationDescriptor
 36  
 {
 37  
 
 38  
     protected Reader webXmlReader;
 39  
     protected String contextRoot;
 40  
     public WebApplicationDescriptor(Reader webXmlReader, String contextRoot )
 41  0
     {
 42  0
         if(webXmlReader == null)
 43  
         {
 44  0
             throw new IllegalArgumentException("webXmlReader cannot be null");
 45  
         }
 46  0
         this.webXmlReader = webXmlReader;
 47  0
         this.contextRoot = contextRoot;
 48  0
     }
 49  
     
 50  
 
 51  
     /**
 52  
      * Load a web.xml file into a Web Application tree
 53  
      * 
 54  
      * @param pathWebXML
 55  
      *                  The path to the web.xml file
 56  
      * @param contexRoot
 57  
      *                  The context root of the web application
 58  
      * @param locale
 59  
      *                  The locale of the display name of the web application
 60  
      * @param displayName
 61  
      *                  The display name of the web application
 62  
      * @return The Java object tree representing web.xml
 63  
      */
 64  
     public MutableWebApplication createWebApplication() throws PortletApplicationException
 65  
     {
 66  
         try
 67  
         {
 68  
 
 69  
             // TODO move config to digester-rules.xml. Example:
 70  
             // http://www.onjava.com/pub/a/onjava/2002/10/23/digester.html?page=3
 71  0
             Digester digester = new Digester();
 72  0
             digester.setClassLoader(this.getClass().getClassLoader());
 73  0
             digester.setValidating(false);
 74  
   
 75  0
             digester.register("-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN", WebApplicationDescriptor.class
 76  
                     .getResource("web-app_2_2.dtd").toString());
 77  0
             digester.register("-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN", WebApplicationDescriptor.class
 78  
                     .getResource("web-app_2_3.dtd").toString());
 79  
                     
 80  0
             digester.addObjectCreate("web-app", WebApplicationDefinitionImpl.class);
 81  
 
 82  0
             digester.addObjectCreate("web-app/security-role", SecurityRoleImpl.class);
 83  0
             digester.addBeanPropertySetter("web-app/security-role/description", "description");
 84  0
             digester.addBeanPropertySetter("web-app/security-role/role-name", "roleName");
 85  0
             digester.addSetNext("web-app/security-role", "addSecurityRole");
 86  
 
 87  0
             WebApplicationDefinitionImpl wd = (WebApplicationDefinitionImpl) digester.parse(webXmlReader);
 88  
 
 89  0
             wd.setContextRoot(contextRoot);
 90  
             //wd.addDescription(locale, displayName);
 91  0
             wd.addDescription(JetspeedLocale.getDefaultLocale(), contextRoot);
 92  0
             return wd;
 93  
 
 94  
         }
 95  0
         catch (Throwable t)
 96  
         {            
 97  0
             String msg = "Could not digester web.xml." + t.toString();            
 98  0
             throw new PortletApplicationException(msg, t);
 99  
         }
 100  
     }
 101  
 
 102  
 }

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