View Javadoc

1   package org.apache.turbine.om.security.peer;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *   http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import org.apache.torque.TorqueException;
23  import org.apache.torque.util.BasePeer;
24  import org.apache.torque.util.Criteria;
25  import org.apache.turbine.util.db.map.TurbineMapBuilder;
26  
27  /***
28   * This class handles all database access for the
29   * ROLE_PERMISSION table.  This table contains all
30   * the permissions for a given role.
31   *
32   * @author <a href="mailto:frank.kim@clearink.com">Frank Y. Kim</a>
33   * @author <a href="mailto:bmclaugh@algx.net">Brett McLaughlin</a>
34   * @author <a href="mailto:john.mcnally@clearink.com">John D. McNally</a>
35   * @author <a href="mailto:jon@collab.net">Jon S. Stevens</a>
36   *
37   * @deprecated Use {@link org.apache.turbine.services.security.torque.TorqueSecurityService}
38   * instead.
39   *
40   * @version $Id: RolePermissionPeer.java 534527 2007-05-02 16:10:59Z tv $
41   */
42  public class RolePermissionPeer extends BasePeer
43  {
44      /*** Serial Version UID */
45      private static final long serialVersionUID = 4149656810524167640L;
46  
47     /*** The map builder for this Peer. */
48      private static final TurbineMapBuilder MAP_BUILDER;
49  
50      /*** The table name for this peer. */
51      public static final String TABLE_NAME;
52  
53      /*** The column name for the permission id field. */
54      public static final String PERMISSION_ID;
55  
56      /*** The column name for the role id field. */
57      public static final String ROLE_ID;
58  
59  
60      static
61      {
62          try
63          {
64              MAP_BUILDER = (TurbineMapBuilder)/* Torque. */getMapBuilder(TurbineMapBuilder.class.getName());
65          }
66          catch (TorqueException e)
67          {
68              log.error("Could not initialize Peer", e);
69              throw new RuntimeException(e);
70          }
71  
72          TABLE_NAME = MAP_BUILDER.getTableRolePermission();
73          PERMISSION_ID = MAP_BUILDER.getRolePermission_PermissionId();
74          ROLE_ID = MAP_BUILDER.getRolePermission_RoleId();
75      }
76  
77      /***
78       * Deletes the mappings for a role_id.
79       *
80       * @param role_id An int with the role id.
81       * @exception Exception a generic exception.
82       */
83      public static void deleteRole(int role_id) throws Exception
84      {
85          Criteria criteria = new Criteria();
86          criteria.add(ROLE_ID, role_id);
87          doDelete(criteria);
88      }
89  
90      /***
91       * Deletes the mappings for a permission_id.
92       *
93       * @param permission_id An int with the permission id.
94       * @exception Exception a generic exception.
95       */
96      public static void deletePermission(int permission_id) throws Exception
97      {
98          Criteria criteria = new Criteria();
99          criteria.add(PERMISSION_ID, permission_id);
100         doDelete(criteria);
101     }
102 }