001package org.apache.fulcrum.security.torque.peer.managers; 002/* 003 * Licensed to the Apache Software Foundation (ASF) under one 004 * or more contributor license agreements. See the NOTICE file 005 * distributed with this work for additional information 006 * regarding copyright ownership. The ASF licenses this file 007 * to you under the Apache License, Version 2.0 (the 008 * "License"); you may not use this file except in compliance 009 * with the License. You may obtain a copy of the License at 010 * 011 * http://www.apache.org/licenses/LICENSE-2.0 012 * 013 * Unless required by applicable law or agreed to in writing, 014 * software distributed under the License is distributed on an 015 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 016 * KIND, either express or implied. See the License for the 017 * specific language governing permissions and limitations 018 * under the License. 019 */ 020import org.apache.avalon.framework.configuration.Configuration; 021import org.apache.avalon.framework.configuration.ConfigurationException; 022import org.apache.fulcrum.security.torque.TorqueAbstractPermissionManager; 023import org.apache.fulcrum.security.torque.peer.Peer; 024import org.apache.fulcrum.security.torque.peer.PeerManagable; 025import org.apache.fulcrum.security.torque.peer.PeerManager; 026import org.apache.fulcrum.security.torque.peer.TorqueTurbinePeer; 027import org.apache.fulcrum.security.util.DataBackendException; 028/** 029 * This implementation persists to a database via Torque. 030 * 031 * @author <a href="mailto:tv@apache.org">Thomas Vandahl</a> 032 * @version $Id:$ 033 */ 034public abstract class PeerPermissionManager extends TorqueAbstractPermissionManager implements PeerManagable 035{ 036 private Boolean customPeer = false; // used for torque which uses per object peer classes 037 038 private String peerClassName; 039 private static final String PEER_CLASS_NAME_KEY = "peerClassName"; 040 transient PeerManager peerManager; 041 042 private String columnName = "PERMISSION_NAME"; 043 044 /** 045 * Avalon Service lifecycle method 046 */ 047 @Override 048 public void configure(Configuration conf) throws ConfigurationException 049 { 050 super.configure( conf ); 051 052 //peerClassName = conf.getChild( PEER_CLASS_NAME_KEY).getValue( "org.apache.fulcrum.security.torque.om.TorqueTurbinePermissionPeer" ); 053 peerClassName = conf.getChild( PEER_CLASS_NAME_KEY).getValue( null ); 054 if (peerClassName != null) { 055 setPeerClassName( peerClassName ); 056 setCustomPeer(true); 057 } 058 } 059 060 @Override 061 public Boolean getCustomPeer() 062 { 063 return customPeer; 064 } 065 066 @Override 067 public void setCustomPeer( Boolean customPeer ) 068 { 069 this.customPeer = customPeer; 070 } 071 072 @Override 073 public String getPeerClassName() 074 { 075 return peerClassName; 076 } 077 078 @Override 079 public void setPeerClassName( String peerClassName ) 080 { 081 this.peerClassName = peerClassName; 082 } 083 084 @Override 085 public Peer getPeerInstance() throws DataBackendException { 086 return getPeerManager().getPeerInstance(getPeerClassName(), TorqueTurbinePeer.class, getClassName()); 087 } 088 089 /** 090 * @return Returns the persistenceHelper. 091 */ 092 @Override 093 public PeerManager getPeerManager() 094 { 095 if (peerManager == null) 096 { 097 peerManager = (PeerManager) resolve(PeerManager.ROLE); 098 } 099 return peerManager; 100 } 101 102 public String getColumnName() { 103 return columnName; 104 } 105 106 public void setColumnName(String columnName) { 107 this.columnName = columnName; 108 } 109 110}