01: package org.apache.turbine.om.security.peer;
02:
03: /*
04: * Licensed to the Apache Software Foundation (ASF) under one
05: * or more contributor license agreements. See the NOTICE file
06: * distributed with this work for additional information
07: * regarding copyright ownership. The ASF licenses this file
08: * to you under the Apache License, Version 2.0 (the
09: * "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.Torque;
23: import org.apache.torque.TorqueException;
24: import org.apache.torque.util.BasePeer;
25: import org.apache.torque.util.Criteria;
26: import org.apache.turbine.util.db.map.TurbineMapBuilder;
27:
28: /**
29: * This class handles all database access for the
30: * ROLE_PERMISSION table. This table contains all
31: * the permissions for a given role.
32: *
33: * @author <a href="mailto:frank.kim@clearink.com">Frank Y. Kim</a>
34: * @author <a href="mailto:bmclaugh@algx.net">Brett McLaughlin</a>
35: * @author <a href="mailto:john.mcnally@clearink.com">John D. McNally</a>
36: * @author <a href="mailto:jon@collab.net">Jon S. Stevens</a>
37: *
38: * @deprecated Use {@link org.apache.turbine.services.security.torque.TorqueSecurityService}
39: * instead.
40: *
41: * @version $Id: RolePermissionPeer.java 571795 2007-09-01 13:09:35Z tv $
42: */
43: public class RolePermissionPeer extends BasePeer {
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: static {
60: try {
61: MAP_BUILDER = (TurbineMapBuilder) Torque
62: .getMapBuilder(TurbineMapBuilder.class.getName());
63: } catch (TorqueException e) {
64: log.error("Could not initialize Peer", e);
65: throw new RuntimeException(e);
66: }
67:
68: TABLE_NAME = MAP_BUILDER.getTableRolePermission();
69: PERMISSION_ID = MAP_BUILDER.getRolePermission_PermissionId();
70: ROLE_ID = MAP_BUILDER.getRolePermission_RoleId();
71: }
72:
73: /**
74: * Deletes the mappings for a role_id.
75: *
76: * @param role_id An int with the role id.
77: * @exception Exception a generic exception.
78: */
79: public static void deleteRole(int role_id) throws Exception {
80: Criteria criteria = new Criteria();
81: criteria.add(ROLE_ID, role_id);
82: doDelete(criteria);
83: }
84:
85: /**
86: * Deletes the mappings for a permission_id.
87: *
88: * @param permission_id An int with the permission id.
89: * @exception Exception a generic exception.
90: */
91: public static void deletePermission(int permission_id)
92: throws Exception {
93: Criteria criteria = new Criteria();
94: criteria.add(PERMISSION_ID, permission_id);
95: doDelete(criteria);
96: }
97: }
|