Coverage report

  %line %branch
org.apache.jetspeed.om.servlet.impl.WebApplicationDefinitionImpl
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.om.servlet.impl;
 18  
 
 19  
 import java.io.Serializable;
 20  
 import java.util.ArrayList;
 21  
 import java.util.Collection;
 22  
 import java.util.Locale;
 23  
 
 24  
 import javax.servlet.ServletContext;
 25  
 
 26  
 import org.apache.commons.logging.Log;
 27  
 import org.apache.commons.logging.LogFactory;
 28  
 import org.apache.jetspeed.om.common.MutableDescription;
 29  
 import org.apache.jetspeed.om.common.MutableDisplayName;
 30  
 import org.apache.jetspeed.om.common.servlet.MutableWebApplication;
 31  
 import org.apache.jetspeed.om.impl.DescriptionImpl;
 32  
 import org.apache.jetspeed.om.impl.DescriptionSetImpl;
 33  
 import org.apache.jetspeed.om.impl.DisplayNameSetImpl;
 34  
 import org.apache.jetspeed.om.impl.WebAppDescriptionImpl;
 35  
 import org.apache.jetspeed.om.impl.WebAppDisplayNameImpl;
 36  
 import org.apache.jetspeed.util.JetspeedLocale;
 37  
 import org.apache.jetspeed.util.JetspeedLongObjectID;
 38  
 import org.apache.pluto.om.common.Description;
 39  
 import org.apache.pluto.om.common.DescriptionSet;
 40  
 import org.apache.pluto.om.common.DisplayName;
 41  
 import org.apache.pluto.om.common.DisplayNameSet;
 42  
 import org.apache.pluto.om.common.ObjectID;
 43  
 import org.apache.pluto.om.common.ParameterSet;
 44  
 import org.apache.pluto.om.servlet.ServletDefinitionList;
 45  
 import org.apache.pluto.om.common.SecurityRole;
 46  
 import org.apache.pluto.om.common.SecurityRoleSet;
 47  
 
 48  
 /**
 49  
  * 
 50  
  * WebApplicationDefinitionImpl
 51  
  * 
 52  
  * @author <a href="mailto:weaver@apache.org">Scott T. Weaver</a>
 53  
  * @version $Id: WebApplicationDefinitionImpl.java 516448 2007-03-09 16:25:47Z ate $
 54  
  *
 55  
  */
 56  0
 public class WebApplicationDefinitionImpl implements MutableWebApplication, Serializable
 57  
 {
 58  
     private Long id;
 59  
     private JetspeedLongObjectID oid;
 60  0
     private Collection displayNames = new ArrayList();
 61  0
     private DisplayNameSetImpl DNCollWrapper = new DisplayNameSetImpl();
 62  
 
 63  0
     private Collection descriptions = new ArrayList();
 64  0
     private DescriptionSetImpl descCollWrapper = new DescriptionSetImpl(DescriptionImpl.TYPE_WEB_APP);
 65  0
     private Collection securityRoles = new ArrayList();
 66  0
     private SecurityRoleSetImpl secRolesListWrapper = new SecurityRoleSetImpl();
 67  
 
 68  
     private String contextRoot;
 69  
     private ParameterSet initParameters;
 70  
 
 71  0
     private static final Log log = LogFactory.getLog(WebApplicationDefinitionImpl.class);
 72  
 
 73  
     /**
 74  
      * @see org.apache.pluto.om.servlet.WebApplicationDefinition#getId()
 75  
      */
 76  
     public ObjectID getId()
 77  
     {
 78  0
         if ( oid == null && id != class="keyword">null )
 79  
         {
 80  0
             oid = new JetspeedLongObjectID(id);
 81  
         }
 82  0
         return oid;
 83  
     }
 84  
 
 85  
     /**
 86  
      * @see org.apache.pluto.om.servlet.WebApplicationDefinition#getDisplayName()
 87  
      */
 88  
     public DisplayName getDisplayName(Locale locale)
 89  
     {
 90  
 
 91  0
         if (displayNames != null)
 92  
         {
 93  0
             DNCollWrapper.setInnerCollection(displayNames);
 94  0
             return DNCollWrapper.get(locale);
 95  
         }
 96  0
         return null;
 97  
 
 98  
     }
 99  
 
 100  
     /**
 101  
      * @see org.apache.pluto.om.servlet.WebApplicationDefinition#getDescription()
 102  
      */
 103  
     public Description getDescription(Locale locale)
 104  
     {
 105  0
         if (descriptions != null)
 106  
         {
 107  0
             descCollWrapper.setInnerCollection(descriptions);
 108  0
             return descCollWrapper.get(locale);
 109  
         }
 110  0
         return null;
 111  
 
 112  
     }
 113  
 
 114  
     /**
 115  
      * @see org.apache.pluto.om.servlet.WebApplicationDefinition#getInitParameterSet()
 116  
      */
 117  
     public ParameterSet getInitParameterSet()
 118  
     {
 119  0
         return initParameters;
 120  
     }
 121  
 
 122  
     /**
 123  
      * @see org.apache.pluto.om.servlet.WebApplicationDefinition#getServletDefinitionList()
 124  
      */
 125  
     public ServletDefinitionList getServletDefinitionList()
 126  
     {
 127  
         // TODO Auto-generated method stub
 128  0
         return null;
 129  
     }
 130  
 
 131  
     /**
 132  
      * @see org.apache.pluto.om.servlet.WebApplicationDefinition#getServletContext(javax.servlet.ServletContext)
 133  
      */
 134  
     public ServletContext getServletContext(ServletContext servletContext)
 135  
     {
 136  
         // TODO Auto-generated method stub
 137  0
         return null;
 138  
     }
 139  
 
 140  
     /**
 141  
      * @see org.apache.pluto.om.servlet.WebApplicationDefinition#getContextRoot()
 142  
      */
 143  
     public String getContextRoot()
 144  
     {
 145  0
         return contextRoot;
 146  
     }
 147  
 
 148  
     /**
 149  
      * @see org.apache.pluto.om.servlet.WebApplicationDefinitionCtrl#setDisplayName(java.lang.String)
 150  
      */
 151  
     public void setDisplayNameSet(DisplayNameSet displayNames)
 152  
     {
 153  0
         this.displayNames = ((DisplayNameSetImpl) displayNames).getInnerCollection();
 154  0
     }
 155  
 
 156  
     /**
 157  
      * @see org.apache.jetspeed.om.common.servlet.WebApplicationComposite#setContextRoot(java.lang.String)
 158  
      */
 159  
     public void setContextRoot(String contextRoot)
 160  
     {
 161  0
         this.contextRoot = contextRoot;
 162  0
     }
 163  
 
 164  
     /**
 165  
      * @see org.apache.jetspeed.om.common.servlet.MutableWebApplication#addDescription(java.util.Locale, java.lang.String)
 166  
      */
 167  
     public void addDescription(Locale locale, String description)
 168  
     {
 169  0
         if (descriptions == null)
 170  
         {
 171  0
             descriptions = new ArrayList();
 172  
         }
 173  0
         descCollWrapper.setInnerCollection(descriptions);
 174  
         try
 175  
         {
 176  0
             MutableDescription descObj = new WebAppDescriptionImpl();
 177  
                 
 178  0
             descObj.setLocale(locale);
 179  0
             descObj.setDescription(description);
 180  0
             descCollWrapper.addDescription(descObj);
 181  
         }
 182  0
         catch (Exception e)
 183  
         {
 184  0
             String msg = "Unable to instantiate Description implementor, " + e.toString();
 185  0
             log.error(msg, e);
 186  0
             throw new IllegalStateException(msg);
 187  0
         }
 188  0
     }
 189  
 
 190  
     /**
 191  
      * @see org.apache.jetspeed.om.common.servlet.MutableWebApplication#addDisplayName(java.util.Locale, java.lang.String)
 192  
      */
 193  
     public void addDisplayName(Locale locale, String name)
 194  
     {
 195  0
         if (displayNames == null)
 196  
         {
 197  0
             displayNames = new ArrayList();
 198  
         }
 199  0
         DNCollWrapper.setInnerCollection(displayNames);
 200  
         try
 201  
         {
 202  0
             MutableDisplayName dn = new WebAppDisplayNameImpl();
 203  
                
 204  0
             dn.setLocale(locale);
 205  0
             dn.setDisplayName(name);
 206  0
             DNCollWrapper.addDisplayName(dn);
 207  
         }
 208  0
         catch (Exception e)
 209  
         {
 210  0
             String msg = "Unable to instantiate DisplayName implementor, " + e.toString();
 211  0
             log.error(msg, e);
 212  0
             throw new IllegalStateException(msg);
 213  0
         }
 214  
 
 215  0
     }
 216  
 
 217  
     /**
 218  
      * @see org.apache.jetspeed.om.common.servlet.MutableWebApplication#setDescriptionSet(org.apache.pluto.om.common.DescriptionSet)
 219  
      */
 220  
     public void setDescriptionSet(DescriptionSet descriptions)
 221  
     {
 222  0
         this.descriptions = ((DescriptionSetImpl) descriptions).getInnerCollection();
 223  0
     }
 224  
 
 225  
     /**
 226  
      *  Remove when Castor is mapped correctly
 227  
      * @deprecated
 228  
      * @return
 229  
      */
 230  
     public String getDescription()
 231  
     {
 232  0
         Description desc = getDescription(JetspeedLocale.getDefaultLocale());
 233  0
         if (desc != null)
 234  
         {
 235  0
             return desc.getDescription();
 236  
         }
 237  0
         return null;
 238  
     }
 239  
 
 240  
     /**
 241  
      *  Remove when Castor is mapped correctly
 242  
      * @deprecated
 243  
      * @param desc
 244  
      */
 245  
     public void setDescription(String desc)
 246  
     {
 247  0
         addDescription(JetspeedLocale.getDefaultLocale(), desc);
 248  0
     }
 249  
 
 250  
     /**
 251  
      * @see org.apache.pluto.om.servlet.WebApplicationDefinition#getSecurityRoles()
 252  
      */
 253  
     public SecurityRoleSet getSecurityRoles()
 254  
     {
 255  0
         secRolesListWrapper.setInnerCollection(securityRoles);
 256  0
         return secRolesListWrapper;
 257  
     }
 258  
     
 259  
     /**
 260  
      * @see org.apache.jetspeed.om.common.servlet.MutableWebApplication#addSecurityRole(org.apache.pluto.om.common.SecurityRole)
 261  
      */
 262  
     public void addSecurityRole(SecurityRole securityRole) 
 263  
     {
 264  0
         secRolesListWrapper.setInnerCollection(securityRoles);
 265  0
         secRolesListWrapper.add(securityRole);
 266  0
     }    
 267  
 }

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