View Javadoc
1   package org.apache.fulcrum.security.torque.peer.managers;
2   /*
3    * Licensed to the Apache Software Foundation (ASF) under one
4    * or more contributor license agreements.  See the NOTICE file
5    * distributed with this work for additional information
6    * regarding copyright ownership.  The ASF licenses this file
7    * to you under the Apache License, Version 2.0 (the
8    * "License"); you may not use this file except in compliance
9    * with the License.  You may obtain a copy of the License at
10   *
11   *   http://www.apache.org/licenses/LICENSE-2.0
12   *
13   * Unless required by applicable law or agreed to in writing,
14   * software distributed under the License is distributed on an
15   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16   * KIND, either express or implied.  See the License for the
17   * specific language governing permissions and limitations
18   * under the License.
19   */
20  import org.apache.avalon.framework.configuration.Configuration;
21  import org.apache.avalon.framework.configuration.ConfigurationException;
22  import org.apache.fulcrum.security.torque.TorqueAbstractPermissionManager;
23  import org.apache.fulcrum.security.torque.peer.Peer;
24  import org.apache.fulcrum.security.torque.peer.PeerManagable;
25  import org.apache.fulcrum.security.torque.peer.PeerManager;
26  import org.apache.fulcrum.security.torque.peer.TorqueTurbinePeer;
27  import org.apache.fulcrum.security.util.DataBackendException;
28  /**
29   * This implementation persists to a database via Torque.
30   *
31   * @author <a href="mailto:tv@apache.org">Thomas Vandahl</a>
32   * @version $Id:$
33   */
34  public abstract class PeerPermissionManager extends TorqueAbstractPermissionManager  implements PeerManagable 
35  {
36      private Boolean customPeer = false;  //  used for torque which uses per object peer classes
37      
38      private String peerClassName;
39      private static final String PEER_CLASS_NAME_KEY = "peerClassName";
40      transient PeerManager peerManager;
41      
42      private String columnName = "PERMISSION_NAME";
43      
44      /**
45       * Avalon Service lifecycle method
46       */ 
47      @Override
48  	public void configure(Configuration conf) throws ConfigurationException
49      {
50         super.configure( conf );
51         
52         //peerClassName = conf.getChild( PEER_CLASS_NAME_KEY).getValue( "org.apache.fulcrum.security.torque.om.TorqueTurbinePermissionPeer" );
53          peerClassName = conf.getChild( PEER_CLASS_NAME_KEY).getValue( null );
54          if (peerClassName != null) {
55              setPeerClassName( peerClassName );
56              setCustomPeer(true);
57          } 
58      }
59      
60      @Override
61  	public Boolean getCustomPeer()
62      {
63          return customPeer;
64      }
65  
66      @Override
67  	public void setCustomPeer( Boolean customPeer )
68      {
69          this.customPeer = customPeer;
70      }
71  
72      @Override
73  	public String getPeerClassName()
74      {
75          return peerClassName;
76      }
77  
78      @Override
79  	public void setPeerClassName( String peerClassName )
80      {
81          this.peerClassName = peerClassName;
82      }
83      
84      @Override
85     	public Peer getPeerInstance() throws DataBackendException {
86             return getPeerManager().getPeerInstance(getPeerClassName(), TorqueTurbinePeer.class, getClassName());
87         }
88         
89         /**
90          * @return Returns the persistenceHelper.
91          */
92         @Override
93     	public PeerManager getPeerManager()
94         {
95             if (peerManager == null)
96             {
97                 peerManager = (PeerManager) resolve(PeerManager.ROLE);
98             }
99             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 }