Coverage report

  %line %branch
org.apache.turbine.services.security.torque.TorquePermission
48% 
100% 

 1  
 package org.apache.turbine.services.security.torque;
 2  
 
 3  
 /*
 4  
  * Copyright 2001-2005 The Apache Software Foundation.
 5  
  *
 6  
  * Licensed under the Apache License, Version 2.0 (the "License")
 7  
  * you may not use this file except in compliance with the License.
 8  
  * You may obtain a copy of the License at
 9  
  *
 10  
  *     http://www.apache.org/licenses/LICENSE-2.0
 11  
  *
 12  
  * Unless required by applicable law or agreed to in writing, software
 13  
  * distributed under the License is distributed on an "AS IS" BASIS,
 14  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 15  
  * See the License for the specific language governing permissions and
 16  
  * limitations under the License.
 17  
  */
 18  
 
 19  
 import org.apache.torque.om.Persistent;
 20  
 
 21  
 import org.apache.turbine.om.security.Permission;
 22  
 import org.apache.turbine.services.security.TurbineSecurity;
 23  
 import org.apache.turbine.util.security.TurbineSecurityException;
 24  
 
 25  
 /**
 26  
  * This class represents a permission given to a Role associated with the
 27  
  * current Session. It is separated from the actual Torque peer object
 28  
  * to be able to replace the Peer with an user supplied Peer (and Object)
 29  
  *
 30  
  * @author <a href="mailto:frank.kim@clearink.com">Frank Y. Kim</a>
 31  
  * @author <a href="mailto:jmcnally@collab.net">John D. McNally</a>
 32  
  * @author <a href="mailto:bmclaugh@algx.net">Brett McLaughlin</a>
 33  
  * @author <a href="mailto:mpoeschl@marmot.at">Martin Poeschl</a>
 34  
  * @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a>
 35  
  * @version $Id: TorquePermission.java 264148 2005-08-29 14:21:04Z henning $
 36  
  */
 37  
 
 38  
 public class TorquePermission
 39  
     extends TorqueObject
 40  
     implements Permission,
 41  
                Comparable
 42  
 {
 43  
     /**
 44  
      * Constructs a Permission
 45  
      */
 46  
     public TorquePermission()
 47  
     {
 48  16
       super();
 49  16
     }
 50  
 
 51  
     /**
 52  
      * Constructs a new Permission with the sepcified name.
 53  
      *
 54  
      * @param name The name of the new object.
 55  
      */
 56  
     public TorquePermission(String name)
 57  
     {
 58  0
         super(name);
 59  0
     }
 60  
 
 61  
     /**
 62  
      * The package private Constructor is used when the PermissionPeerManager
 63  
      * has retrieved a list of Database Objects from the peer and
 64  
      * must 'wrap' them into TorquePermission Objects.
 65  
      * You should not use it directly!
 66  
      *
 67  
      * @param obj An Object from the peer
 68  
      */
 69  
 
 70  
     public TorquePermission(Persistent obj)
 71  
     {
 72  298
         super(obj);
 73  298
     }
 74  
 
 75  
     /**
 76  
      * Returns the underlying Object for the Peer
 77  
      *
 78  
      * Used in the PermissionPeerManager when building a new Criteria.
 79  
      *
 80  
      * @return The underlying Persistent Object
 81  
      *
 82  
      */
 83  
 
 84  
     public Persistent getPersistentObj()
 85  
     {
 86  2042
         if (obj == null)
 87  
         {
 88  14
             obj = PermissionPeerManager.newPersistentInstance();
 89  
         }
 90  2042
         return obj;
 91  
     }
 92  
 
 93  
     /**
 94  
      * Returns the name of this object.
 95  
      *
 96  
      * @return The name of the object.
 97  
      */
 98  
     public String getName()
 99  
     {
 100  374
         return PermissionPeerManager.getPermissionName(getPersistentObj());
 101  
     }
 102  
 
 103  
     /**
 104  
      * Sets the name of this object.
 105  
      *
 106  
      * @param name The name of the object.
 107  
      */
 108  
     public void setName(String name)
 109  
     {
 110  14
         PermissionPeerManager.setPermissionName(getPersistentObj(), name);
 111  14
     }
 112  
 
 113  
     /**
 114  
      * Gets the Id of this object
 115  
      *
 116  
      * @return The Id of the object
 117  
      */
 118  
     public int getId()
 119  
     {
 120  0
         return PermissionPeerManager.getIdAsObj(getPersistentObj()).intValue();
 121  
     }
 122  
 
 123  
     /**
 124  
      * Gets the Id of this object
 125  
      *
 126  
      * @return The Id of the object
 127  
      */
 128  
     public Integer getIdAsObj()
 129  
     {
 130  328
         return PermissionPeerManager.getIdAsObj(getPersistentObj());
 131  
     }
 132  
 
 133  
     /**
 134  
      * Sets the Id of this object
 135  
      *
 136  
      * @param id The new Id
 137  
      */
 138  
     public void setId(int id)
 139  
     {
 140  0
         PermissionPeerManager.setId(getPersistentObj(), id);
 141  0
     }
 142  
 
 143  
     /**
 144  
      * Creates a new Permission in the system.
 145  
      *
 146  
      * @param name The name of the new Permission.
 147  
      * @return An object representing the new Permission.
 148  
      * @throws TurbineSecurityException if the Permission could not be created.
 149  
      * @deprecated Please use the createPermission method in TurbineSecurity.
 150  
      */
 151  
     public static Permission create(String name)
 152  
         throws TurbineSecurityException
 153  
     {
 154  0
         return TurbineSecurity.createPermission(name);
 155  
     }
 156  
 
 157  
     /**
 158  
      * Makes changes made to the Permission attributes permanent.
 159  
      *
 160  
      * @throws TurbineSecurityException if there is a problem while
 161  
      *  saving data.
 162  
      */
 163  
     public void save()
 164  
         throws TurbineSecurityException
 165  
     {
 166  0
         TurbineSecurity.savePermission(this);
 167  0
     }
 168  
 
 169  
     /**
 170  
      * Removes a permission from the system.
 171  
      *
 172  
      * @throws TurbineSecurityException if the Permission could not be removed.
 173  
      */
 174  
     public void remove()
 175  
         throws TurbineSecurityException
 176  
     {
 177  0
         TurbineSecurity.removePermission(this);
 178  0
     }
 179  
 
 180  
     /**
 181  
      * Renames the permission.
 182  
      *
 183  
      * @param name The new Permission name.
 184  
      * @throws TurbineSecurityException if the Permission could not be renamed.
 185  
      */
 186  
     public void rename(String name)
 187  
         throws TurbineSecurityException
 188  
     {
 189  0
         TurbineSecurity.renamePermission(this, name);
 190  0
     }
 191  
 }
 192  
 
 193  
 
 194  
 

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