View Javadoc

1   package org.apache.turbine.om.security.peer;
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.util.BasePeer;
20  import org.apache.torque.util.Criteria;
21  import org.apache.turbine.util.db.map.TurbineMapBuilder;
22  
23  /***
24   * This class handles all database access for the
25   * ROLE_PERMISSION table.  This table contains all
26   * the permissions for a given role.
27   *
28   * @author <a href="mailto:frank.kim@clearink.com">Frank Y. Kim</a>
29   * @author <a href="mailto:bmclaugh@algx.net">Brett McLaughlin</a>
30   * @author <a href="mailto:john.mcnally@clearink.com">John D. McNally</a>
31   * @author <a href="mailto:jon@collab.net">Jon S. Stevens</a>
32   * @version $Id: RolePermissionPeer.java 264148 2005-08-29 14:21:04Z henning $
33   */
34  public class RolePermissionPeer extends BasePeer
35  {
36      /*** Serial Version UID */
37      private static final long serialVersionUID = 4149656810524167640L;
38  
39     /*** The map builder for this Peer. */
40      private static final TurbineMapBuilder MAP_BUILDER = (TurbineMapBuilder)
41              getMapBuilder(TurbineMapBuilder.class.getName());
42  
43      /*** The table name for this peer. */
44      public static final String TABLE_NAME = MAP_BUILDER.getTableRolePermission();
45  
46      /*** The column name for the permission id field. */
47      public static final String PERMISSION_ID
48              = MAP_BUILDER.getRolePermission_PermissionId();
49  
50      /*** The column name for the role id field. */
51      public static final String ROLE_ID = MAP_BUILDER.getRolePermission_RoleId();
52  
53  
54      /***
55       * Deletes the mappings for a role_id.
56       *
57       * @param role_id An int with the role id.
58       * @exception Exception a generic exception.
59       */
60      public static void deleteRole(int role_id) throws Exception
61      {
62          Criteria criteria = new Criteria();
63          criteria.add(ROLE_ID, role_id);
64          doDelete(criteria);
65      }
66  
67      /***
68       * Deletes the mappings for a permission_id.
69       *
70       * @param permission_id An int with the permission id.
71       * @exception Exception a generic exception.
72       */
73      public static void deletePermission(int permission_id) throws Exception
74      {
75          Criteria criteria = new Criteria();
76          criteria.add(PERMISSION_ID, permission_id);
77          doDelete(criteria);
78      }
79  }