Author: gk
Date: Wed Nov  2 15:23:30 2016
New Revision: 1767705

URL: http://svn.apache.org/viewvc?rev=1767705&view=rev
Log:
- added manager and abstract classes to allow Fulcrum Security 1.1.0 to work,
- added interfaces to OM classes (Torque 4.0 could not handle this in schema) 
- added LogoutUser action with getUserFromSession (fixed in Torque 4.0-SNAPSHOT)
- replaced JNDI with SharedPoolDataSourceFactory as default
- updated changes.xml

Added:
    
turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/src/main/java/fulcrum/
    
turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/src/main/java/fulcrum/security/
    
turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/src/main/java/fulcrum/security/torque/
    
turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/src/main/java/fulcrum/security/torque/TorqueAbstractUserManager.java
   (with props)
    
turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/src/main/java/fulcrum/security/torque/turbine/
    
turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/src/main/java/fulcrum/security/torque/turbine/TorqueAbstractTurbineGroup.java
   (with props)
    
turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/src/main/java/fulcrum/security/torque/turbine/TorqueAbstractTurbinePermission.java
   (with props)
    
turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/src/main/java/fulcrum/security/torque/turbine/TorqueAbstractTurbineRole.java
   (with props)
    
turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/src/main/java/fulcrum/security/torque/turbine/TorqueAbstractTurbineUser.java
   (with props)
    
turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/src/main/java/fulcrum/security/torque/turbine/TorqueTurbineGroupManagerImpl.java
   (with props)
    
turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/src/main/java/fulcrum/security/torque/turbine/TorqueTurbineRoleManagerImpl.java
   (with props)
    
turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/src/main/java/fulcrum/security/torque/turbine/TorqueTurbineUserManagerImpl.java
   (with props)
    
turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/src/main/java/modules/actions/LogoutUser.java
   (with props)
    
turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/src/main/java/om/
    
turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/src/main/java/om/TurbineGroup.java
   (with props)
    
turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/src/main/java/om/TurbineGroupPeer.java
   (with props)
    
turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/src/main/java/om/TurbineGroupPeerImpl.java
   (with props)
    
turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/src/main/java/om/TurbinePermission.java
   (with props)
    
turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/src/main/java/om/TurbineRole.java
   (with props)
    
turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/src/main/java/om/TurbineRolePeer.java
   (with props)
    
turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/src/main/java/om/TurbineRolePeerImpl.java
   (with props)
    
turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/src/main/java/om/TurbineRolePermission.java
   (with props)
    
turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/src/main/java/om/TurbineUser.java
   (with props)
    
turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/src/main/java/om/TurbineUserPeer.java
   (with props)
    
turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/src/main/java/om/TurbineUserPeerImpl.java
   (with props)
    
turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/src/main/webapp/templates/screens/Error.vm
   (with props)
Modified:
    turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/changes/changes.xml
    
turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/docs/README.txt
    
turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/docs/sample-mysql-data/turbine-security-data.sql
    
turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/pom.xml
    
turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/src/main/java/modules/actions/SecureAction.java
    
turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/src/main/torque-schema/torque-security-data.xml
    
turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/src/main/torque-schema/torque-security-schema.xml
    
turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/conf/Torque.properties
    
turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/conf/TurbineResources.properties
    
turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/conf/componentConfiguration.xml
    
turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/conf/log4j.properties
    
turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/conf/roleConfiguration.xml

Modified: 
turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/changes/changes.xml
URL: 
http://svn.apache.org/viewvc/turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/changes/changes.xml?rev=1767705&r1=1767704&r2=1767705&view=diff
==============================================================================
--- turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/changes/changes.xml 
(original)
+++ turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/changes/changes.xml 
Wed Nov  2 15:23:30 2016
@@ -24,7 +24,28 @@
   </properties>
 
   <body>
-    <release version="1.0.0" date="in Subversion">
+   <release version="1.0.1" date="in Subversion">
+       <action dev="gk" type="update">
+       Fulcrum Torque Security added manager, om classes
+      </action>
+       <action dev="painter" type="update">
+       MySQL is now default, added readme, docs, helper sql..
+      </action>
+      <action dev="gk" type="update">
+       Update schema to torque / intake 4.0, dependencies, configurations
+       Update to MemoryGroupManagerImpl, Fulcrum     
+      </action>
+      <action dev="gk" type="add">
+        Jetty support
+      </action>
+      <action dev="tv" type="fix">
+        TRB-95
+      </action>
+      <action dev="gk" type="update ">
+        Update to Turbine 4-M2
+      </action>
+    </release>
+    <release version="1.0.0" date="2012-11-06">
       <action dev="tv" type="fix">
         Fixed missing dependencies and wrong class names as reported on the 
mailing list
       </action>

Modified: 
turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/docs/README.txt
URL: 
http://svn.apache.org/viewvc/turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/docs/README.txt?rev=1767705&r1=1767704&r2=1767705&view=diff
==============================================================================
--- 
turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/docs/README.txt
 (original)
+++ 
turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/docs/README.txt
 Wed Nov  2 15:23:30 2016
@@ -17,6 +17,17 @@ specific language governing permissions
 under the License.
 *#
 
+Notice
+
+About this archetype 
+ 
+Turbine Version: Turbine 4.0-M2. Be aware and
+  - keep groups/roles lower case
+  - abstract classes and managers are included
+  (because of some minor bugs in Fulcrum Security 1.1.0, which should be fixed 
in v 1.1.1/Turbine 4.0)
+  - LogoutAction is included (fixed getUserFromSession)
+  - om stub classes are included (until configurable in schema with Torque 
version 2.1)
+  
 
 Quick Guide to using the new Turbine 4.0-M2 maven archetype 
 for skeleton application generation
@@ -71,6 +82,8 @@ mvn jetty:run         ## Now you can lau
 
 Open a web browser to http://localhost:8081/app
 
+Login should work with user admin/password.
+
 To enable application development in Eclipse, run the following command 
 and then import the project into Eclipse.
 

Modified: 
turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/docs/sample-mysql-data/turbine-security-data.sql
URL: 
http://svn.apache.org/viewvc/turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/docs/sample-mysql-data/turbine-security-data.sql?rev=1767705&r1=1767704&r2=1767705&view=diff
==============================================================================
--- 
turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/docs/sample-mysql-data/turbine-security-data.sql
 (original)
+++ 
turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/docs/sample-mysql-data/turbine-security-data.sql
 Wed Nov  2 15:23:30 2016
@@ -10,34 +10,30 @@ INSERT INTO TURBINE_USER (USER_ID,LOGIN_
 
 INSERT INTO TURBINE_USER 
(USER_ID,LOGIN_NAME,PASSWORD_VALUE,FIRST_NAME,LAST_NAME)
     VALUES (2,'user','password','','User');
+    
+INSERT INTO TURBINE_USER 
(USER_ID,LOGIN_NAME,PASSWORD_VALUE,FIRST_NAME,LAST_NAME)
+    VALUES (2,'anon','nopw','','Anon');
 
-INSERT INTO TURBINE_PERMISSION (PERMISSION_ID,PERMISSION_NAME)
-    VALUES (1,'TurbineAdmin');
-
-INSERT INTO TURBINE_PERMISSION (PERMISSION_ID,PERMISSION_NAME)
-    VALUES (2,'Turbine');
-
-INSERT INTO TURBINE_ROLE (ROLE_ID,ROLE_NAME)
-    VALUES (1,'TurbineAdmin');
-
-INSERT INTO TURBINE_ROLE (ROLE_ID,ROLE_NAME)
-    VALUES (2,'TurbineUser');
-
-INSERT INTO TURBINE_GROUP (GROUP_ID,GROUP_NAME)
-    VALUES (1,'global');
-
-INSERT INTO TURBINE_GROUP (GROUP_ID,GROUP_NAME)
-    VALUES (2,'Turbine');
-
-INSERT INTO TURBINE_ROLE_PERMISSION (ROLE_ID,PERMISSION_ID)
-    VALUES (1,1);
-
-INSERT INTO TURBINE_ROLE_PERMISSION (ROLE_ID,PERMISSION_ID)
-    VALUES (2,2);
-
-INSERT INTO TURBINE_USER_GROUP_ROLE (USER_ID,GROUP_ID,ROLE_ID)
-    VALUES (1,2,1);
-
-INSERT INTO TURBINE_USER_GROUP_ROLE (USER_ID,GROUP_ID,ROLE_ID)
-    VALUES (2,2,2);
+INSERT INTO `turbine_permission` (`PERMISSION_ID`, `PERMISSION_NAME`) VALUES
+(2, 'Turbine'),
+(1, 'TurbineAdmin');
+
+INSERT INTO `turbine_role` (`ROLE_ID`, `ROLE_NAME`) VALUES
+(1, 'turbineadmin'),
+(2, 'turbineuser');
+
+INSERT INTO `turbine_group` (`GROUP_ID`, `GROUP_NAME`) VALUES
+(1, 'global'),
+(2, 'Turbine');
+
+INSERT INTO `turbine_role_permission` (`ROLE_ID`, `PERMISSION_ID`) VALUES
+(1, 1),
+(2, 2);
+
+INSERT INTO `turbine_user_group_role` (`USER_ID`, `GROUP_ID`, `ROLE_ID`) VALUES
+(1, 1, 1),
+(3, 1, 2),
+(1, 2, 1),
+(2, 2, 2);
+    
 

Modified: 
turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/pom.xml
URL: 
http://svn.apache.org/viewvc/turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/pom.xml?rev=1767705&r1=1767704&r2=1767705&view=diff
==============================================================================
--- 
turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/pom.xml
 (original)
+++ 
turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/pom.xml
 Wed Nov  2 15:23:30 2016
@@ -66,56 +66,56 @@ under the License.
                     
<schemaDir>#var("basedir")/src/main/torque-schema</schemaDir>
                     <useClasspath>true</useClasspath>
                     <runOnlyOnSchemaChange>false</runOnlyOnSchemaChange>
-                    <targetDatabase>mysql</targetDatabase>
+                    
<targetDatabase>${turbine_database_adapter}</targetDatabase>
                 </configuration>
                 <executions>
-                                       <execution>
-                                               <id>torque-om</id>
-                                               <phase>generate-sources</phase>
-                                               <goals>
-                                                       <goal>generate</goal>
-                                               </goals>
-                                               <configuration>
-                                                       
<packaging>classpath</packaging>
-                                                       
<configPackage>org.apache.torque.templates.om</configPackage>
-                                                       
<sourceDir>#var("basedir")/src/main/torque-schema</sourceDir>
-                                                       
<loglevel>error</loglevel>
-                                                       <options>
-                                                               
<torque.database>${turbine_database_adapter}</torque.database>
-                                                               
<torque.om.package>${package}.om</torque.om.package>
-                                                               
<torque.om.addGetByNameMethods>false</torque.om.addGetByNameMethods>
-                                                               
<torque.om.save.saveException>TorqueException</torque.om.save.saveException>
-                                                               
<torque.om.useIsForBooleanGetters>true</torque.om.useIsForBooleanGetters>
-                                                               
<torque.om.useManagers>false</torque.om.useManagers>
-                                                               
<torque.om.addTimeStamp>true</torque.om.addTimeStamp>
-                                                               
<torque.om.objectIsCaching>true</torque.om.objectIsCaching>
-                                                               
<torque.om.save.addSaveMethods>true</torque.om.save.addSaveMethods>
-                                                               
<torque.om.addGetByNameMethods>true</torque.om.addGetByNameMethods>
-                                                               
<torque.om.complexObjectModel>true</torque.om.complexObjectModel>
-                                                       </options>
-                                                       <outputDirMap>
-                                                               
<modifiable>#var("project.build.sourceDirectory")</modifiable>
-                                                       </outputDirMap>
-                                               </configuration>
-                                       </execution>
-                                       <execution>
-                                               
<id>torque-sql-${turbine_database_adapter}</id>
-                                               <phase>generate-sources</phase>
-                                               <goals>
-                                                       <goal>generate</goal>
-                                               </goals>
-                                               <configuration>
-                                                       
<packaging>classpath</packaging>
-                                                       
<configPackage>org.apache.torque.templates.sql</configPackage>
-                                                       
<sourceDir>#var("basedir")/src/main/torque-schema</sourceDir>
-                                                       
<defaultOutputDir>#var("project.build.directory")/generated-sql/torque/${turbine_database_adapter}</defaultOutputDir>
-                                                       
<defaultOutputDirUsage>none</defaultOutputDirUsage>
-                                                       
<loglevel>error</loglevel>
-                                                       <options>
-                                                               
<torque.database>${turbine_database_adapter}</torque.database>
-                                                       </options>
-                                               </configuration>
-                                       </execution>
+          <execution>
+            <id>torque-om</id>
+            <phase>generate-sources</phase>
+            <goals>
+              <goal>generate</goal>
+            </goals>
+            <configuration>
+              <packaging>classpath</packaging>
+              <configPackage>org.apache.torque.templates.om</configPackage>
+              <sourceDir>#var("basedir")/src/main/torque-schema</sourceDir>
+              <loglevel>error</loglevel>
+              <options>
+                <torque.database>${turbine_database_adapter}</torque.database>
+                <torque.om.package>${package}.om</torque.om.package>
+                
<torque.om.addGetByNameMethods>false</torque.om.addGetByNameMethods>
+                
<torque.om.save.saveException>TorqueException</torque.om.save.saveException>
+                
<torque.om.useIsForBooleanGetters>true</torque.om.useIsForBooleanGetters>
+                <torque.om.useManagers>false</torque.om.useManagers>
+                <torque.om.addTimeStamp>true</torque.om.addTimeStamp>
+                <torque.om.objectIsCaching>true</torque.om.objectIsCaching>
+                
<torque.om.save.addSaveMethods>true</torque.om.save.addSaveMethods>
+                
<torque.om.addGetByNameMethods>true</torque.om.addGetByNameMethods>
+                
<torque.om.complexObjectModel>true</torque.om.complexObjectModel>
+              </options>
+              <outputDirMap>
+                <modifiable>#var("project.build.sourceDirectory")</modifiable>
+              </outputDirMap>
+            </configuration>
+          </execution>
+          <execution>
+            <id>torque-sql-${turbine_database_adapter}</id>
+            <phase>generate-sources</phase>
+            <goals>
+              <goal>generate</goal>
+            </goals>
+            <configuration>
+              <packaging>classpath</packaging>
+              <configPackage>org.apache.torque.templates.sql</configPackage>
+              <sourceDir>#var("basedir")/src/main/torque-schema</sourceDir>
+              
<defaultOutputDir>#var("project.build.directory")/generated-sql/torque/${turbine_database_adapter}</defaultOutputDir>
+              <defaultOutputDirUsage>none</defaultOutputDirUsage>
+              <loglevel>error</loglevel>
+              <options>
+                <torque.database>${turbine_database_adapter}</torque.database>
+              </options>
+            </configuration>
+          </execution>
                 </executions>
                 <dependencies>
                   <dependency>
@@ -141,40 +141,47 @@ under the License.
             </plugin>
 
 
-                       <!-- Required to execute torque database build -->
-                       <plugin>
-                               <groupId>org.codehaus.mojo</groupId>
-                               <artifactId>sql-maven-plugin</artifactId>
-                               <version>1.5</version>
-                               <configuration>
-
-                                       <!-- Please update with your database 
configuration -->
-                                       
<driver>${turbine_database_driver}</driver>
-                                       
<url>${turbine_database_url}${turbine_database_name}</url>
-                                       
<username>${turbine_database_user}</username>
-                                       
<password>${turbine_database_password}</password>
-                                       <onError>continue</onError>
-                                       <autocommit>true</autocommit>
-                                       <fileset>
-                                               
<basedir>${project.build.directory}/generated-sql/torque/${turbine_database_adapter}</basedir>
-                                               <!-- 
basedir>${basedir}/target/generated-sql</basedir -->
-                                               <includes>
-                                                       <include>*.sql</include>
-                                               </includes>
-                                       </fileset>
-                               </configuration>
-                               
-                               <!-- update with your database driver 
dependency -->
-                               <dependencies>
-                                       <dependency>
-                                               
<artifactId>mysql-connector-java</artifactId>
-                                               <groupId>mysql</groupId>
-                                               <version>5.1.40</version>
-                                       </dependency>
-                               </dependencies>
-                       </plugin>
-                               
-            
+      <!-- Required to execute torque database build -->
+      <plugin>
+        <groupId>org.codehaus.mojo</groupId>
+        <artifactId>sql-maven-plugin</artifactId>
+        <version>1.5</version>
+        <configuration>
+
+          <!-- Please update with your database configuration -->
+          <driver>${turbine_database_driver}</driver>
+          <url>${turbine_database_url}${turbine_database_name}</url>
+          <username>${turbine_database_user}</username>
+          <password>${turbine_database_password}</password>
+          <onError>continue</onError>
+          <autocommit>true</autocommit>
+          <!-- this is mysql specific -->
+           <sqlCommand>SET FOREIGN_KEY_CHECKS=0</sqlCommand>
+          <fileset>
+              
<basedir>${project.build.directory}/generated-sql/torque/${turbine_database_adapter}</basedir>
+              <!-- basedir>${basedir}/target/generated-sql</basedir -->
+              <includes>
+                <include>*.sql</include>
+              </includes>
+           </fileset>
+           <srcFiles>
+              
<srcFile>${basedir}/docs/sample-mysql-data/application-data.sql</srcFile>
+              
<srcFile>${basedir}/docs/sample-mysql-data/turbine-security-data.sql</srcFile>
+           </srcFiles>
+           <sqlCommand>SET FOREIGN_KEY_CHECKS=1</sqlCommand>
+        </configuration>
+        
+        <!-- update with your database driver dependency -->
+        
+        <dependencies>
+          <dependency>
+            <artifactId>mysql-connector-java</artifactId>
+            <groupId>mysql</groupId>
+            <version>5.1.40</version>
+          </dependency>
+        </dependencies>
+      </plugin>
+
             <!-- jetty:run checks deployed war http://localhost:8081/app/ 
             
             Using jetty 8 as supporting java 6. Other specs cft. 
http://www.eclipse.org/jetty/documentation/9.3.0.v20150612/what-jetty-version.html
@@ -201,12 +208,12 @@ under the License.
 
     <dependencies>
     
-               <!-- update with the database driver of your choice -->
-               <dependency>
-                       <artifactId>mysql-connector-java</artifactId>
-                       <groupId>mysql</groupId>
-                       <version>5.1.40</version>
-               </dependency>    
+    <!-- update with the database driver of your choice -->
+    <dependency>
+      <artifactId>mysql-connector-java</artifactId>
+      <groupId>mysql</groupId>
+      <version>5.1.40</version>
+    </dependency>    
         <dependency>
             <groupId>javax.activation</groupId>
             <artifactId>activation</artifactId>
@@ -276,4 +283,5 @@ under the License.
         <maven.compile.target>1.6</maven.compile.target>
         <project.build.sourceEncoding>utf-8</project.build.sourceEncoding>
     </properties>
+    
 </project>

Added: 
turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/src/main/java/fulcrum/security/torque/TorqueAbstractUserManager.java
URL: 
http://svn.apache.org/viewvc/turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/src/main/java/fulcrum/security/torque/TorqueAbstractUserManager.java?rev=1767705&view=auto
==============================================================================
--- 
turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/src/main/java/fulcrum/security/torque/TorqueAbstractUserManager.java
 (added)
+++ 
turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/src/main/java/fulcrum/security/torque/TorqueAbstractUserManager.java
 Wed Nov  2 15:23:30 2016
@@ -0,0 +1,400 @@
+package  ${package}.fulcrum.security.torque;
+
+#*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements.  See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership.  The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License.  You may obtain a copy of the License at
+*
+*   http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied.  See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*#
+
+import java.sql.Connection;
+import java.util.List;
+
+import org.apache.avalon.framework.configuration.Configuration;
+import org.apache.avalon.framework.configuration.ConfigurationException;
+import org.apache.fulcrum.security.entity.User;
+import org.apache.fulcrum.security.spi.AbstractUserManager;
+import org.apache.fulcrum.security.util.DataBackendException;
+import org.apache.fulcrum.security.util.EntityExistsException;
+import org.apache.fulcrum.security.util.UnknownEntityException;
+import org.apache.fulcrum.security.util.UserSet;
+import org.apache.torque.NoRowsException;
+import org.apache.torque.TooManyRowsException;
+import org.apache.torque.TorqueException;
+import org.apache.torque.util.Transaction;
+
+import  org.apache.fulcrum.security.torque.TorqueAbstractSecurityEntity;
+/**
+ * This implementation persists to a database via Torque.
+ *
+ * @author <a href="mailto:[email protected]";>Thomas Vandahl</a>
+ * @version $Id:$
+ */
+public abstract class TorqueAbstractUserManager extends AbstractUserManager
+{
+    private Boolean customPeer = false;  //  used for torque which uses per 
object peer classes
+    
+    private String peerClassName;
+    private static final String PEER_CLASS_NAME_KEY = "peerClassName";
+    
+    /**
+     * Avalon Service lifecycle method
+     */
+    public void configure(Configuration conf) throws ConfigurationException
+    {
+       super.configure( conf );
+       
+        peerClassName = conf.getChild( PEER_CLASS_NAME_KEY).getValue( null );
+        if (peerClassName != null) {
+            setPeerClassName( peerClassName );
+            setCustomPeer(true);
+        } 
+    }
+    
+    public Boolean getCustomPeer()
+    {
+        return customPeer;
+    }
+
+    public void setCustomPeer( Boolean customPeer )
+    {
+        this.customPeer = customPeer;
+    }
+
+    public String getPeerClassName()
+    {
+        return peerClassName;
+    }
+
+    public void setPeerClassName( String peerClassName )
+    {
+        this.peerClassName = peerClassName;
+    }
+    /**
+     * Get all specialized Users
+     *
+     * @param con a database connection
+     *
+     * @return a List of User instances
+     *
+     * @throws TorqueException if any database error occurs
+     */
+    protected abstract <T extends User> List<T> doSelectAllUsers(Connection 
con)
+        throws TorqueException;
+
+    /**
+     * Get a specialized User by name
+     *
+     * @param name the name of the group
+     * @param con a database connection
+     *
+     * @return a User instance
+     *
+     * @throws NoRowsException if no such group exists
+     * @throws TooManyRowsException if multiple groups with the given name 
exist
+     * @throws TorqueException if any other database error occurs
+     */
+    protected abstract <T extends User> T doSelectByName(String name, 
Connection con)
+        throws NoRowsException, TooManyRowsException, TorqueException;
+
+    /**
+     * Get a specialized User by id
+     *
+     * @param id the id of the group
+     * @param con a database connection
+     *
+     * @return a User instance
+     *
+     * @throws NoRowsException if no such group exists
+     * @throws TooManyRowsException if multiple groups with the given id exist
+     * @throws TorqueException if any other database error occurs
+     */
+    protected abstract <T extends User> T doSelectById(Integer id, Connection 
con)
+        throws NoRowsException, TooManyRowsException, TorqueException;
+
+    /**
+    * Removes an user account from the system.
+    *
+    * @param user the object describing the account to be removed.
+    * @throws DataBackendException if there was an error accessing the data
+    *         backend.
+    * @throws UnknownEntityException if the user account is not present.
+    */
+    public synchronized void removeUser(User user) throws 
DataBackendException, UnknownEntityException
+    {
+        try
+        {
+            ((TorqueAbstractSecurityEntity)user).delete();
+        }
+        catch (TorqueException e)
+        {
+            throw new DataBackendException("Removing User '" + user.getName() 
+ "' failed", e);
+        }
+    }
+
+    /**
+       * Creates new user account with specified attributes.
+       *
+       * @param user the object describing account to be created.
+       *
+       * @throws DataBackendException if there was an error accessing the
+       *         data backend.
+       * @throws EntityExistsException if the user account already exists.
+       */
+    protected synchronized <T extends User> T persistNewUser(T user) throws 
DataBackendException
+    {
+        try
+        {
+            ((TorqueAbstractSecurityEntity)user).save();
+        }
+        catch (Exception e)
+        {
+            throw new DataBackendException("Adding User '" + user.getName() + 
"' failed", e);
+        }
+
+        return user;
+    }
+
+    /**
+       * Stores User attributes. The User is required to exist in the system.
+       *
+       * @param user The User to be stored.
+       * @throws DataBackendException if there was an error accessing the data
+       *         backend.
+       * @throws UnknownEntityException if the role does not exist.
+       */
+    public synchronized void saveUser(User user) throws DataBackendException, 
UnknownEntityException
+    {
+        if (checkExists(user))
+        {
+            try
+            {
+                TorqueAbstractSecurityEntity u = 
(TorqueAbstractSecurityEntity)user;
+                u.setNew(false);
+                u.save();
+            }
+            catch (Exception e)
+            {
+                throw new DataBackendException("Saving User '" + 
user.getName() + "' failed", e);
+            }
+        }
+        else
+        {
+            throw new UnknownEntityException("Unknown user '" + user + "'");
+        }
+    }
+
+    /**
+     * Check whether a specified user's account exists.
+     *
+     * The login name is used for looking up the account.
+     *
+     * @param userName The name of the user to be checked.
+     * @return true if the specified account exists
+     * @throws DataBackendException if there was an error accessing
+     *         the data backend.
+     */
+    public boolean checkExists(String userName) throws DataBackendException
+    {
+        boolean exists = false;
+
+        Connection con = null;
+
+        try
+        {
+            con = 
Transaction.begin(((TorqueAbstractSecurityEntity)getUserInstance()).getDatabaseName());
+
+            doSelectByName(userName, con);
+
+            Transaction.commit(con);
+            con = null;
+
+            exists = true;
+        }
+        catch (NoRowsException e)
+        {
+            exists = false;
+        }
+        catch (TooManyRowsException e)
+        {
+            throw new DataBackendException("Multiple Users with same username 
'" + userName + "'");
+        }
+        catch (TorqueException e)
+        {
+            throw new DataBackendException("Error retrieving user 
information", e);
+        }
+        finally
+        {
+            if (con != null)
+            {
+                Transaction.safeRollback(con);
+            }
+        }
+
+        return exists;
+    }
+
+    /**
+     * Retrieve a user from persistent storage using username as the
+     * key.
+     *
+     * @param userName the name of the user.
+     * @return an User object.
+     * @exception UnknownEntityException if the user's account does not
+     *            exist in the database.
+     * @exception DataBackendException if there is a problem accessing the
+     *            storage.
+     */
+    public <T extends User> T getUser(String userName) throws 
UnknownEntityException, DataBackendException
+    {
+        T user = null;
+        Connection con = null;
+
+        try
+        {
+            System.out.println("transaction for database: " 
+((TorqueAbstractSecurityEntity)getUserInstance()).getDatabaseName());
+            con = 
Transaction.begin(((TorqueAbstractSecurityEntity)getUserInstance()).getDatabaseName());
+
+            user = doSelectByName(userName.toLowerCase(), con);
+
+            // Add attached objects if they exist
+            ((TorqueAbstractSecurityEntity)user).retrieveAttachedObjects(con);
+
+            Transaction.commit(con);
+            con = null;
+        }
+        catch (NoRowsException e)
+        {
+            throw new UnknownEntityException("Unknown user '" + userName + 
"'",e);
+        }
+        catch (TooManyRowsException e)
+        {
+            throw new DataBackendException("Multiple Users with same username 
'" + userName + "'");
+        }
+        catch (TorqueException e)
+        {
+            throw new DataBackendException("Error retrieving user 
information", e);
+        }
+        finally
+        {
+            if (con != null)
+            {
+                Transaction.safeRollback(con);
+            }
+        }
+
+        return user;
+    }
+
+    /**
+       * Retrieves all users defined in the system.
+       *
+       * @return the names of all users defined in the system.
+       * @throws DataBackendException if there was an error accessing the data
+       *         backend.
+       */
+    public UserSet getAllUsers() throws DataBackendException
+    {
+        UserSet userSet = new UserSet();
+        Connection con = null;
+
+        try
+        {
+            con = 
Transaction.begin(((TorqueAbstractSecurityEntity)getUserInstance()).getDatabaseName());
+
+            List<User> users = doSelectAllUsers(con);
+
+            for (User user : users)
+            {
+                // Add attached objects if they exist
+                
((TorqueAbstractSecurityEntity)user).retrieveAttachedObjects(con);
+
+                userSet.add(user);
+            }
+
+            Transaction.commit(con);
+            con = null;
+        }
+        catch (TorqueException e)
+        {
+            throw new DataBackendException("Error retrieving all users", e);
+        }
+        finally
+        {
+            if (con != null)
+            {
+                Transaction.safeRollback(con);
+            }
+        }
+
+        return userSet;
+    }
+
+    /**
+     * Retrieve a User object with specified id.
+     *
+     * @param id
+     *            the id of the User.
+     * @return an object representing the User with specified id.
+     * @throws DataBackendException
+     *             if there was an error accessing the data backend.
+     * @throws UnknownEntityException
+     *             if the user does not exist.
+     */
+    public <T extends User> T getUserById(Object id) throws 
DataBackendException, UnknownEntityException
+    {
+        T user;
+
+        if (id != null && id instanceof Integer)
+        {
+            Connection con = null;
+
+            try
+            {
+                con = 
Transaction.begin(((TorqueAbstractSecurityEntity)getUserInstance()).getDatabaseName());
+
+                user = doSelectById((Integer)id, con);
+
+                // Add attached objects if they exist
+                
((TorqueAbstractSecurityEntity)user).retrieveAttachedObjects(con);
+
+                Transaction.commit(con);
+                con = null;
+            }
+            catch (NoRowsException e)
+            {
+                throw new UnknownEntityException("User with id '" + id + "' 
does not exist.", e);
+            }
+            catch (TorqueException e)
+            {
+                throw new DataBackendException("Error retrieving user 
information", e);
+            }
+            finally
+            {
+                if (con != null)
+                {
+                    Transaction.safeRollback(con);
+                }
+            }
+        }
+        else
+        {
+            throw new UnknownEntityException("Invalid user id '" + id + "'");
+        }
+
+        return user;
+    }
+    
+}

Propchange: 
turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/src/main/java/fulcrum/security/torque/TorqueAbstractUserManager.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/src/main/java/fulcrum/security/torque/turbine/TorqueAbstractTurbineGroup.java
URL: 
http://svn.apache.org/viewvc/turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/src/main/java/fulcrum/security/torque/turbine/TorqueAbstractTurbineGroup.java?rev=1767705&view=auto
==============================================================================
--- 
turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/src/main/java/fulcrum/security/torque/turbine/TorqueAbstractTurbineGroup.java
 (added)
+++ 
turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/src/main/java/fulcrum/security/torque/turbine/TorqueAbstractTurbineGroup.java
 Wed Nov  2 15:23:30 2016
@@ -0,0 +1,140 @@
+package ${package}.fulcrum.security.torque.turbine;
+#*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements.  See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership.  The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License.  You may obtain a copy of the License at
+*
+*   http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied.  See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*#
+import java.sql.Connection;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.fulcrum.security.model.turbine.entity.TurbineGroup;
+import org.apache.fulcrum.security.model.turbine.entity.TurbineUserGroupRole;
+import org.apache.fulcrum.security.torque.om.TorqueTurbineUserGroupRole;
+import 
org.apache.fulcrum.security.torque.turbine.TorqueAbstractTurbineTurbineSecurityEntity;
+import org.apache.torque.TorqueException;
+import org.apache.torque.criteria.Criteria;
+import org.apache.torque.om.SimpleKey;
+
+import ${package}.om.TurbineGroupPeer;
+import ${package}.om.TurbineUserGroupRolePeer;
+/**
+ * This abstract class provides the SecurityInterface to the managers.
+ *
+ * @author <a href="mailto:[email protected]";>Thomas Vandahl</a>
+ * @version $Id:$
+ */
+public abstract class TorqueAbstractTurbineGroup extends 
TorqueAbstractTurbineTurbineSecurityEntity
+    implements TurbineGroup
+{
+    /** Serial version */
+       private static final long serialVersionUID = -6230312046016785990L;
+
+    /**
+     * Forward reference to generated code
+     *
+     * Get a list of association objects, pre-populated with their TurbineRole
+     * objects.
+     *
+     * @param criteria Criteria to define the selection of records
+     * @param con a database connection
+     * @throws TorqueException
+     *
+     * @return a list of User/Group/Role relations
+     */
+    protected List<${package}.om.TurbineUserGroupRole> 
getTurbineUserGroupRolesJoinTurbineRole(Criteria criteria, Connection con)
+        throws TorqueException
+    {
+        criteria.and(TurbineUserGroupRolePeer.GROUP_ID, getEntityId() );
+        return TurbineUserGroupRolePeer.doSelectJoinTurbineRole(criteria, con);
+    }
+
+    /**
+     * @see 
org.apache.fulcrum.security.torque.TorqueAbstractSecurityEntity#getDatabaseName()
+     */
+    @Override
+       public String getDatabaseName()
+    {
+        return TurbineGroupPeer.DATABASE_NAME;
+    }
+
+    /**
+     * @see 
org.apache.fulcrum.security.torque.TorqueAbstractSecurityEntity#retrieveAttachedObjects(java.sql.Connection)
+     */
+    @Override
+       public void retrieveAttachedObjects(Connection con) throws 
TorqueException
+    {
+        Set<TurbineUserGroupRole> userGroupRoleSet = new 
HashSet<TurbineUserGroupRole>();
+
+        List<${package}.om.TurbineUserGroupRole> ugrs = 
getTurbineUserGroupRolesJoinTurbineRole(new Criteria(), con);
+
+        for (${package}.om.TurbineUserGroupRole ttugr : ugrs)
+        {
+            TurbineUserGroupRole ugr = new TurbineUserGroupRole();
+            ugr.setGroup(this);
+            ugr.setRole(ttugr.getTurbineRole());
+            ugr.setUser(ttugr.getTurbineUser(con));
+            userGroupRoleSet.add(ugr);
+        }
+
+        setUserGroupRoleSet(userGroupRoleSet);
+    }
+
+    /**
+     * @see 
org.apache.fulcrum.security.torque.TorqueAbstractSecurityEntity#update(java.sql.Connection)
+     */
+    @Override
+       public void update(Connection con) throws TorqueException
+    {
+       Set<TurbineUserGroupRole> userGroupRoleSet = getUserGroupRoleSet();
+        if (userGroupRoleSet != null)
+        {
+            Criteria criteria = new Criteria();
+
+            /* remove old entries */
+            criteria.where(TurbineUserGroupRolePeer.GROUP_ID, getEntityId());
+            TurbineUserGroupRolePeer.doDelete(criteria, con);
+
+            for (TurbineUserGroupRole ugr : userGroupRoleSet)
+            {
+               TorqueTurbineUserGroupRole ttugr = new 
TorqueTurbineUserGroupRole();
+                ttugr.setGroupId((Integer)ugr.getGroup().getId());
+                ttugr.setUserId((Integer)ugr.getUser().getId());
+                ttugr.setRoleId((Integer)ugr.getRole().getId());
+                ttugr.save(con);
+            }
+        }
+
+        try
+        {
+            save(con);
+        }
+        catch (Exception e)
+        {
+            throw new TorqueException(e);
+        }
+    }
+
+    /**
+     * @see 
org.apache.fulcrum.security.torque.TorqueAbstractSecurityEntity#delete()
+     */
+    @Override
+       public void delete() throws TorqueException
+    {
+        TurbineGroupPeer.doDelete(SimpleKey.keyFor(getEntityId()));
+    }
+}

Propchange: 
turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/src/main/java/fulcrum/security/torque/turbine/TorqueAbstractTurbineGroup.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/src/main/java/fulcrum/security/torque/turbine/TorqueAbstractTurbinePermission.java
URL: 
http://svn.apache.org/viewvc/turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/src/main/java/fulcrum/security/torque/turbine/TorqueAbstractTurbinePermission.java?rev=1767705&view=auto
==============================================================================
--- 
turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/src/main/java/fulcrum/security/torque/turbine/TorqueAbstractTurbinePermission.java
 (added)
+++ 
turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/src/main/java/fulcrum/security/torque/turbine/TorqueAbstractTurbinePermission.java
 Wed Nov  2 15:23:30 2016
@@ -0,0 +1,207 @@
+package ${package}.fulcrum.security.torque.turbine;
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import java.sql.Connection;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.fulcrum.security.entity.Role;
+import org.apache.fulcrum.security.model.turbine.entity.TurbinePermission;
+import org.apache.fulcrum.security.torque.TorqueAbstractSecurityEntity;
+import org.apache.fulcrum.security.torque.om.TorqueTurbineRolePermission;
+import org.apache.fulcrum.security.util.RoleSet;
+import org.apache.torque.TorqueException;
+import org.apache.torque.criteria.Criteria;
+import org.apache.torque.om.SimpleKey;
+
+import ${package}.om.TurbinePermissionPeer;
+import ${package}.om.TurbineRolePermission;
+import ${package}.om.TurbineRolePermissionPeer;
+/**
+ * This abstract class provides the SecurityInterface to the managers.
+ *
+ * @author <a href="mailto:[email protected]";>Thomas Vandahl</a>
+ * @version $Id:$
+ */
+public abstract class TorqueAbstractTurbinePermission extends 
TorqueAbstractSecurityEntity
+    implements TurbinePermission
+{
+    /** Serial version */
+       private static final long serialVersionUID = -5313324873688923207L;
+
+       /** a cache of role objects */
+    private Set<Role> roleSet = null;
+
+    /**
+     * Forward reference to generated code
+     *
+     * Get a list of association objects, pre-populated with their 
TorqueTurbineRole
+     * objects.
+     *
+     * @param criteria Criteria to define the selection of records
+     * @param con a database connection
+     * @throws TorqueException
+     *
+     * @return a list of Role/Permission relations
+     */
+    protected List<TurbineRolePermission> 
getTurbineRolePermissionsJoinTurbineRole(Criteria criteria, Connection con)
+        throws TorqueException
+    {
+        criteria.and(TurbineRolePermissionPeer.PERMISSION_ID, getEntityId() );
+        return TurbineRolePermissionPeer.doSelectJoinTurbineRole(criteria, 
con);
+    }
+
+    /**
+     * @see 
org.apache.fulcrum.security.model.turbine.entity.TurbinePermission#addRole(org.apache.fulcrum.security.entity.Role)
+     */
+    @Override
+       public void addRole(Role role)
+    {
+        getRoles().add(role);
+    }
+
+    /**
+     * @see 
org.apache.fulcrum.security.model.turbine.entity.TurbinePermission#getRoles()
+     */
+    @Override
+       public RoleSet getRoles()
+    {
+        if (roleSet == null)
+        {
+            roleSet = new RoleSet();
+        }
+        else if(!(roleSet instanceof RoleSet))
+        {
+            roleSet = new RoleSet(roleSet);
+        }
+
+        return (RoleSet)roleSet;
+    }
+
+    /**
+     * @see 
org.apache.fulcrum.security.model.turbine.entity.TurbinePermission#getRolesAsSet()
+     */
+    @Override
+       @SuppressWarnings("unchecked")
+       public <T extends Role> Set<T> getRolesAsSet()
+    {
+        return (Set<T>)roleSet;
+    }
+
+    /**
+     * @see 
org.apache.fulcrum.security.model.turbine.entity.TurbinePermission#removeRole(org.apache.fulcrum.security.entity.Role)
+     */
+    @Override
+       public void removeRole(Role role)
+    {
+        getRoles().remove(role);
+    }
+
+    /**
+     * @see 
org.apache.fulcrum.security.model.turbine.entity.TurbinePermission#setRoles(org.apache.fulcrum.security.util.RoleSet)
+     */
+    @Override
+       public void setRoles(RoleSet roleSet)
+    {
+        if (roleSet != null)
+        {
+            this.roleSet = roleSet;
+        }
+        else
+        {
+            this.roleSet = new RoleSet();
+        }
+    }
+
+    /**
+     * @see 
org.apache.fulcrum.security.model.turbine.entity.TurbinePermission#setRolesAsSet(java.util.Set)
+     */
+    @Override
+       public <T extends Role> void setRolesAsSet(Set<T> roles)
+    {
+        setRoles(new RoleSet(roles));
+    }
+
+    /**
+     * @see 
org.apache.fulcrum.security.torque.TorqueAbstractSecurityEntity#getDatabaseName()
+     */
+    @Override
+       public String getDatabaseName()
+    {
+        return TurbinePermissionPeer.DATABASE_NAME;
+    }
+
+    /**
+     * @see 
org.apache.fulcrum.security.torque.TorqueAbstractSecurityEntity#retrieveAttachedObjects(java.sql.Connection)
+     */
+    @Override
+       public void retrieveAttachedObjects(Connection con) throws 
TorqueException
+    {
+        this.roleSet = new RoleSet();
+
+        List<TurbineRolePermission> rolepermissions = 
getTurbineRolePermissionsJoinTurbineRole(new Criteria(), con);
+
+        for (TurbineRolePermission ttrp : rolepermissions)
+        {
+            roleSet.add(ttrp.getTurbineRole());
+        }
+    }
+
+    /**
+     * @see 
org.apache.fulcrum.security.torque.TorqueAbstractSecurityEntity#update(java.sql.Connection)
+     */
+    @Override
+       public void update(Connection con) throws TorqueException
+    {
+        if (roleSet != null)
+        {
+            Criteria criteria = new Criteria();
+
+            /* remove old entries */
+            criteria.where(TurbineRolePermissionPeer.PERMISSION_ID, 
getEntityId());
+            TurbineRolePermissionPeer.doDelete(criteria, con);
+
+            for (Role r : roleSet)
+            {
+                TorqueTurbineRolePermission rp = new 
TorqueTurbineRolePermission();
+                rp.setRoleId((Integer)r.getId());
+                rp.setPermissionId(getEntityId());
+                rp.save(con);
+            }
+        }
+
+        try
+        {
+            save(con);
+        }
+        catch (Exception e)
+        {
+            throw new TorqueException(e);
+        }
+    }
+
+    /**
+     * @see 
org.apache.fulcrum.security.torque.TorqueAbstractSecurityEntity#delete()
+     */
+    @Override
+       public void delete() throws TorqueException
+    {
+        TurbinePermissionPeer.doDelete(SimpleKey.keyFor(getEntityId()));
+    }
+}

Propchange: 
turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/src/main/java/fulcrum/security/torque/turbine/TorqueAbstractTurbinePermission.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/src/main/java/fulcrum/security/torque/turbine/TorqueAbstractTurbineRole.java
URL: 
http://svn.apache.org/viewvc/turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/src/main/java/fulcrum/security/torque/turbine/TorqueAbstractTurbineRole.java?rev=1767705&view=auto
==============================================================================
--- 
turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/src/main/java/fulcrum/security/torque/turbine/TorqueAbstractTurbineRole.java
 (added)
+++ 
turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/src/main/java/fulcrum/security/torque/turbine/TorqueAbstractTurbineRole.java
 Wed Nov  2 15:23:30 2016
@@ -0,0 +1,264 @@
+package ${package}.fulcrum.security.torque.turbine;
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import java.sql.Connection;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.fulcrum.security.entity.Permission;
+import org.apache.fulcrum.security.model.turbine.entity.TurbineRole;
+import org.apache.fulcrum.security.model.turbine.entity.TurbineUserGroupRole;
+import org.apache.fulcrum.security.torque.om.TorqueTurbineRolePermission;
+import org.apache.fulcrum.security.torque.om.TorqueTurbineUserGroupRole;
+import 
org.apache.fulcrum.security.torque.turbine.TorqueAbstractTurbineTurbineSecurityEntity;
+import org.apache.fulcrum.security.util.PermissionSet;
+import org.apache.torque.TorqueException;
+import org.apache.torque.criteria.Criteria;
+import org.apache.torque.om.SimpleKey;
+
+import ${package}.om.TurbineRolePeer;
+import ${package}.om.TurbineRolePermission;
+import ${package}.om.TurbineRolePermissionPeer;
+import ${package}.om.TurbineUserGroupRolePeer;
+/**
+ * This abstract class provides the SecurityInterface to the managers.
+ *
+ * @author <a href="mailto:[email protected]";>Thomas Vandahl</a>
+ * @version $Id:$
+ */
+public abstract class TorqueAbstractTurbineRole extends 
TorqueAbstractTurbineTurbineSecurityEntity
+    implements TurbineRole
+{
+    /** Serial version */
+       private static final long serialVersionUID = -1782236723198646728L;
+
+       /** a cache of permission objects */
+    private Set<Permission> permissionSet = null;
+
+    /**
+     * Forward reference to generated code
+     *
+     * Get a list of association objects, pre-populated with their 
TorqueTurbinePermission
+     * objects.
+     *
+     * @param criteria Criteria to define the selection of records
+     * @param con a database connection
+     * @throws TorqueException
+     *
+     * @return a list of Role/Permission relations
+     */
+    protected List<TurbineRolePermission> 
getTurbineRolePermissionsJoinTurbinePermission(Criteria criteria, Connection 
con)
+        throws TorqueException
+    {
+        criteria.and(TurbineRolePermissionPeer.ROLE_ID, getEntityId() );
+        return 
TurbineRolePermissionPeer.doSelectJoinTurbinePermission(criteria, con);
+    }
+
+    /**
+     * Forward reference to generated code
+     *
+     * Get a list of association objects, pre-populated with their TurbineGroup
+     * objects.
+     *
+     * @param criteria Criteria to define the selection of records
+     * @param con a database connection
+     * @throws TorqueException
+     *
+     * @return a list of User/Group/Role relations
+     */
+    protected List<${package}.om.TurbineUserGroupRole> 
getTurbineUserGroupRolesJoinTurbineGroup(Criteria criteria, Connection con)
+        throws TorqueException
+    {
+        criteria.and(TurbineUserGroupRolePeer.ROLE_ID, getEntityId() );
+        return TurbineUserGroupRolePeer.doSelectJoinTurbineGroup(criteria, 
con);
+    }
+
+    /**
+     * @see 
org.apache.fulcrum.security.model.turbine.entity.TurbineRole#addPermission(org.apache.fulcrum.security.entity.Permission)
+     */
+    @Override
+       public void addPermission(Permission permission)
+    {
+        getPermissions().add(permission);
+    }
+
+    /**
+     * @see 
org.apache.fulcrum.security.model.turbine.entity.TurbineRole#getPermissions()
+     */
+    @Override
+       public PermissionSet getPermissions()
+    {
+        if (permissionSet == null)
+        {
+            permissionSet = new PermissionSet();
+        }
+        else if(!(permissionSet instanceof PermissionSet))
+        {
+            permissionSet = new PermissionSet(permissionSet);
+        }
+
+        return (PermissionSet)permissionSet;
+    }
+
+    /**
+     * @see 
org.apache.fulcrum.security.model.turbine.entity.TurbineRole#getPermissionsAsSet()
+     */
+    @Override
+       @SuppressWarnings("unchecked")
+       public <T extends Permission> Set<T> getPermissionsAsSet()
+    {
+        return (Set<T>)permissionSet;
+    }
+
+    /**
+     * @see 
org.apache.fulcrum.security.model.turbine.entity.TurbineRole#removePermission(org.apache.fulcrum.security.entity.Permission)
+     */
+    @Override
+       public void removePermission(Permission permission)
+    {
+        getPermissions().remove(permission);
+    }
+
+    /**
+     * @see 
org.apache.fulcrum.security.model.turbine.entity.TurbineRole#setPermissions(org.apache.fulcrum.security.util.PermissionSet)
+     */
+    @Override
+       public void setPermissions(PermissionSet permissionSet)
+    {
+        if (permissionSet != null)
+        {
+            this.permissionSet = permissionSet;
+        }
+        else
+        {
+            this.permissionSet = new PermissionSet();
+        }
+    }
+
+    /**
+     * @see 
org.apache.fulcrum.security.model.turbine.entity.TurbineRole#setPermissionsAsSet(java.util.Set)
+     */
+    @Override
+       public <T extends Permission> void setPermissionsAsSet(Set<T> 
permissions)
+    {
+        setPermissions(new PermissionSet(permissions));
+    }
+
+    /**
+     * @see 
org.apache.fulcrum.security.torque.TorqueAbstractSecurityEntity#getDatabaseName()
+     */
+    @Override
+       public String getDatabaseName()
+    {
+        return TurbineRolePeer.DATABASE_NAME;
+    }
+
+    /**
+     * @see 
org.apache.fulcrum.security.torque.TorqueAbstractSecurityEntity#retrieveAttachedObjects(java.sql.Connection)
+     */
+    @Override
+       public void retrieveAttachedObjects(Connection con) throws 
TorqueException
+    {
+        this.permissionSet = new PermissionSet();
+
+        List<TurbineRolePermission> rolepermissions = 
getTurbineRolePermissionsJoinTurbinePermission(new Criteria(), con);
+
+        for (TurbineRolePermission ttrp : rolepermissions)
+        {
+            permissionSet.add(ttrp.getTurbinePermission());
+        }
+
+        Set<TurbineUserGroupRole> userGroupRoleSet = new 
HashSet<TurbineUserGroupRole>();
+
+        List<${package}.om.TurbineUserGroupRole> ugrs = 
getTurbineUserGroupRolesJoinTurbineGroup(new Criteria(), con);
+
+        for (${package}.om.TurbineUserGroupRole ttugr : ugrs)
+        {
+            TurbineUserGroupRole ugr = new TurbineUserGroupRole();
+            ugr.setRole(this);
+            ugr.setGroup(ttugr.getTurbineGroup());
+            ugr.setUser(ttugr.getTurbineUser(con));
+            userGroupRoleSet.add(ugr);
+        }
+
+        setUserGroupRoleSet(userGroupRoleSet);
+    }
+
+    /**
+     * @see 
org.apache.fulcrum.security.torque.TorqueAbstractSecurityEntity#update(java.sql.Connection)
+     */
+    @Override
+       public void update(Connection con) throws TorqueException
+    {
+        if (permissionSet != null)
+        {
+            Criteria criteria = new Criteria();
+
+            /* remove old entries */
+            criteria.where(TurbineRolePermissionPeer.ROLE_ID, getEntityId());
+            TurbineRolePermissionPeer.doDelete(criteria, con);
+
+            for (Permission p : permissionSet)
+            {
+               TorqueTurbineRolePermission rp = new 
TorqueTurbineRolePermission();
+                rp.setPermissionId((Integer)p.getId());
+                rp.setRoleId(getEntityId());
+                rp.save(con);
+            }
+        }
+
+       Set<TurbineUserGroupRole> userGroupRoleSet = getUserGroupRoleSet();
+        if (userGroupRoleSet != null)
+        {
+            Criteria criteria = new Criteria();
+
+            /* remove old entries */
+            criteria.where(TurbineUserGroupRolePeer.ROLE_ID, getEntityId());
+            TurbineUserGroupRolePeer.doDelete(criteria, con);
+
+            for (TurbineUserGroupRole ugr : userGroupRoleSet)
+            {
+                TorqueTurbineUserGroupRole ttugr = new 
TorqueTurbineUserGroupRole();
+                ttugr.setGroupId((Integer)ugr.getGroup().getId());
+                ttugr.setUserId((Integer)ugr.getUser().getId());
+                ttugr.setRoleId((Integer)ugr.getRole().getId());
+                ttugr.save(con);
+            }
+        }
+
+        try
+        {
+            save(con);
+        }
+        catch (Exception e)
+        {
+            throw new TorqueException(e);
+        }
+    }
+
+    /**
+     * @see 
org.apache.fulcrum.security.torque.TorqueAbstractSecurityEntity#delete()
+     */
+    @Override
+       public void delete() throws TorqueException
+    {
+        TurbineRolePeer.doDelete(SimpleKey.keyFor(getEntityId()));
+    }
+}

Propchange: 
turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/src/main/java/fulcrum/security/torque/turbine/TorqueAbstractTurbineRole.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/src/main/java/fulcrum/security/torque/turbine/TorqueAbstractTurbineUser.java
URL: 
http://svn.apache.org/viewvc/turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/src/main/java/fulcrum/security/torque/turbine/TorqueAbstractTurbineUser.java?rev=1767705&view=auto
==============================================================================
--- 
turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/src/main/java/fulcrum/security/torque/turbine/TorqueAbstractTurbineUser.java
 (added)
+++ 
turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/src/main/java/fulcrum/security/torque/turbine/TorqueAbstractTurbineUser.java
 Wed Nov  2 15:23:30 2016
@@ -0,0 +1,139 @@
+package ${package}.fulcrum.security.torque.turbine;
+#*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements.  See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership.  The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License.  You may obtain a copy of the License at
+*
+*   http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied.  See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*#
+import java.sql.Connection;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.fulcrum.security.model.turbine.entity.TurbineUser;
+import org.apache.fulcrum.security.model.turbine.entity.TurbineUserGroupRole;
+import org.apache.fulcrum.security.torque.om.TorqueTurbineUserGroupRole;
+import org.apache.fulcrum.security.torque.om.TorqueTurbineUserGroupRolePeer;
+import org.apache.fulcrum.security.torque.om.TorqueTurbineUserPeer;
+import 
org.apache.fulcrum.security.torque.turbine.TorqueAbstractTurbineTurbineSecurityEntity;
+import org.apache.torque.TorqueException;
+import org.apache.torque.criteria.Criteria;
+import org.apache.torque.om.SimpleKey;
+/**
+ * This abstract class provides the SecurityInterface to the managers.
+ *
+ * @author <a href="mailto:[email protected]";>Thomas Vandahl</a>
+ * @version $Id:$
+ */
+public abstract class TorqueAbstractTurbineUser extends 
TorqueAbstractTurbineTurbineSecurityEntity
+    implements TurbineUser
+{
+    /** Serial version */
+       private static final long serialVersionUID = -7255623655281852566L;
+
+    /**
+     * Forward reference to generated code
+     *
+     * Get a list of association objects, pre-populated with their 
TorqueTurbineRole
+     * objects.
+     *
+     * @param criteria Criteria to define the selection of records
+     * @param con a database connection
+     * @throws TorqueException
+     *
+     * @return a list of User/Group/Role relations
+     */
+    protected List<TorqueTurbineUserGroupRole> 
getTorqueTurbineUserGroupRolesJoinTorqueTurbineRole(Criteria criteria, 
Connection con)
+        throws TorqueException
+    {
+        criteria.and(TorqueTurbineUserGroupRolePeer.USER_ID, getEntityId() );
+        return 
TorqueTurbineUserGroupRolePeer.doSelectJoinTorqueTurbineRole(criteria, con);
+    }
+
+    /**
+     * @see 
org.apache.fulcrum.security.torque.TorqueAbstractSecurityEntity#getDatabaseName()
+     */
+    @Override
+       public String getDatabaseName()
+    {
+        return TorqueTurbineUserPeer.DATABASE_NAME;
+    }
+
+    /**
+     * @see 
org.apache.fulcrum.security.torque.TorqueAbstractSecurityEntity#retrieveAttachedObjects(java.sql.Connection)
+     */
+    @Override
+       public void retrieveAttachedObjects(Connection con) throws 
TorqueException
+    {
+        Set<TurbineUserGroupRole> userGroupRoleSet = new 
HashSet<TurbineUserGroupRole>();
+
+        List<TorqueTurbineUserGroupRole> ugrs = 
getTorqueTurbineUserGroupRolesJoinTorqueTurbineRole(new Criteria(), con);
+
+        for (TorqueTurbineUserGroupRole ttugr : ugrs)
+        {
+            TurbineUserGroupRole ugr = new TurbineUserGroupRole();
+            ugr.setUser(this);
+            ugr.setRole(ttugr.getTorqueTurbineRole());
+            ugr.setGroup(ttugr.getTorqueTurbineGroup(con));
+            userGroupRoleSet.add(ugr);
+        }
+
+        setUserGroupRoleSet(userGroupRoleSet);
+    }
+
+    /**
+     * @see 
org.apache.fulcrum.security.torque.TorqueAbstractSecurityEntity#update(java.sql.Connection)
+     */
+    @Override
+       public void update(Connection con) throws TorqueException
+    {
+       Set<TurbineUserGroupRole> userGroupRoleSet = getUserGroupRoleSet();
+        if (userGroupRoleSet != null)
+        {
+            Criteria criteria = new Criteria();
+
+            /* remove old entries */
+            criteria.where(TorqueTurbineUserGroupRolePeer.USER_ID, 
getEntityId());
+            TorqueTurbineUserGroupRolePeer.doDelete(criteria, con);
+
+            for (TurbineUserGroupRole ugr : userGroupRoleSet)
+            {
+                TorqueTurbineUserGroupRole ttugr = new 
TorqueTurbineUserGroupRole();
+                ttugr.setGroupId((Integer)ugr.getGroup().getId());
+                ttugr.setUserId((Integer)ugr.getUser().getId());
+                ttugr.setRoleId((Integer)ugr.getRole().getId());
+                ttugr.save(con);
+            }
+        }
+
+        try
+        {
+            save(con);
+        }
+        catch (Exception e)
+        {
+            throw new TorqueException(e);
+        }
+    }
+
+    /**
+     * @see 
org.apache.fulcrum.security.torque.TorqueAbstractSecurityEntity#delete()
+     */
+    @Override
+       public void delete() throws TorqueException
+    {
+        TorqueTurbineUserPeer.doDelete(SimpleKey.keyFor(getEntityId()));
+    }
+}

Propchange: 
turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/src/main/java/fulcrum/security/torque/turbine/TorqueAbstractTurbineUser.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/src/main/java/fulcrum/security/torque/turbine/TorqueTurbineGroupManagerImpl.java
URL: 
http://svn.apache.org/viewvc/turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/src/main/java/fulcrum/security/torque/turbine/TorqueTurbineGroupManagerImpl.java?rev=1767705&view=auto
==============================================================================
--- 
turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/src/main/java/fulcrum/security/torque/turbine/TorqueTurbineGroupManagerImpl.java
 (added)
+++ 
turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/src/main/java/fulcrum/security/torque/turbine/TorqueTurbineGroupManagerImpl.java
 Wed Nov  2 15:23:30 2016
@@ -0,0 +1,144 @@
+package ${package}.fulcrum.security.torque.turbine;
+#*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements.  See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership.  The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License.  You may obtain a copy of the License at
+*
+*   http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied.  See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*#
+import java.sql.Connection;
+import java.util.List;
+
+import org.apache.fulcrum.security.entity.Group;
+import org.apache.fulcrum.security.torque.TorqueAbstractGroupManager;
+import org.apache.fulcrum.security.torque.peer.Peer;
+import org.apache.fulcrum.security.torque.peer.PeerManagable;
+import org.apache.fulcrum.security.torque.peer.PeerManager;
+import org.apache.fulcrum.security.torque.peer.TorqueTurbinePeer;
+import org.apache.fulcrum.security.util.DataBackendException;
+import org.apache.torque.NoRowsException;
+import org.apache.torque.TooManyRowsException;
+import org.apache.torque.TorqueException;
+import org.apache.torque.criteria.Criteria;
+
+import ${package}.om.TurbineGroupPeer;
+/**
+ * This implementation persists to a database via Torque.
+ *
+ * @author <a href="mailto:[email protected]";>Thomas Vandahl</a>
+ * @version $Id:$
+ */
+public class TorqueTurbineGroupManagerImpl extends TorqueAbstractGroupManager 
implements PeerManagable
+{
+    
+    PeerManager peerManager;
+    /**
+     * @see 
org.apache.fulcrum.security.torque.TorqueAbstractGroupManager#doSelectAllGroups(java.sql.Connection)
+     */
+    @Override
+       @SuppressWarnings("unchecked")
+       protected <T extends Group> List<T> doSelectAllGroups(Connection con) 
throws TorqueException
+    {
+        Criteria criteria = new Criteria(TurbineGroupPeer.DATABASE_NAME);
+        
+        if ( (getCustomPeer())) {
+            try
+            {
+                return ((TorqueTurbinePeer<T>)getPeerInstance()).doSelect( 
criteria, con );
+            }
+            catch ( DataBackendException e )
+            {
+                throw new TorqueException( e );
+            }
+        } else {
+            return (List<T>) TurbineGroupPeer.doSelect(criteria, con);
+        }
+
+
+    }
+
+    /**
+     * @see 
org.apache.fulcrum.security.torque.TorqueAbstractGroupManager#doSelectById(java.lang.Integer,
 java.sql.Connection)
+     */
+    @Override
+       @SuppressWarnings("unchecked")
+       protected <T extends Group> T doSelectById(Integer id, Connection con) 
throws NoRowsException, TooManyRowsException, TorqueException
+    {
+        if ( (getCustomPeer())) {
+            try
+            {
+                return ((TorqueTurbinePeer<T>) 
getPeerInstance()).retrieveByPK( id, con );
+            }
+            catch ( DataBackendException e )
+            {
+                throw new TorqueException( e );
+            }
+        } else {
+            return  (T)  TurbineGroupPeer.retrieveByPK(id, con);
+        }
+
+    }
+
+    /**
+     * @see 
org.apache.fulcrum.security.torque.TorqueAbstractGroupManager#doSelectByName(java.lang.String,
 java.sql.Connection)
+     */
+    @Override
+       @SuppressWarnings("unchecked")
+       protected <T extends Group> T doSelectByName(String name, Connection 
con) throws NoRowsException, TooManyRowsException, TorqueException
+    {
+        Criteria criteria = new Criteria(TurbineGroupPeer.DATABASE_NAME);
+        criteria.where(TurbineGroupPeer.GROUP_NAME, name);
+        criteria.setIgnoreCase(true);
+        criteria.setSingleRecord(true);
+        List<T> groups = null;
+        
+        if ( (getCustomPeer())) {
+            try
+            {
+                
+                groups = ((TorqueTurbinePeer<T>) getPeerInstance()).doSelect( 
criteria, con );
+            }
+            catch ( DataBackendException e )
+            {
+                throw new TorqueException( e );
+            }
+        } else {
+            groups = (List<T>) TurbineGroupPeer.doSelect(criteria, con);
+        }
+
+        if (groups.isEmpty())
+        {
+            throw new NoRowsException(name);
+        }
+
+        return groups.get(0);
+    }
+    
+    public Peer getPeerInstance() throws DataBackendException {
+        return getPeerManager().getPeerInstance(getPeerClassName(), 
TorqueTurbinePeer.class, getClassName());
+    }
+    
+    /**
+     * @return Returns the persistenceHelper.
+     */
+    @Override
+       public PeerManager getPeerManager()
+    {
+        if (peerManager == null)
+        {
+            peerManager = (PeerManager) resolve(PeerManager.ROLE);
+        }
+        return peerManager;
+    }
+}

Propchange: 
turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/src/main/java/fulcrum/security/torque/turbine/TorqueTurbineGroupManagerImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/src/main/java/fulcrum/security/torque/turbine/TorqueTurbineRoleManagerImpl.java
URL: 
http://svn.apache.org/viewvc/turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/src/main/java/fulcrum/security/torque/turbine/TorqueTurbineRoleManagerImpl.java?rev=1767705&view=auto
==============================================================================
--- 
turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/src/main/java/fulcrum/security/torque/turbine/TorqueTurbineRoleManagerImpl.java
 (added)
+++ 
turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/src/main/java/fulcrum/security/torque/turbine/TorqueTurbineRoleManagerImpl.java
 Wed Nov  2 15:23:30 2016
@@ -0,0 +1,140 @@
+package ${package}.fulcrum.security.torque.turbine;
+#*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements.  See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership.  The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License.  You may obtain a copy of the License at
+*
+*   http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied.  See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*#
+import java.sql.Connection;
+import java.util.List;
+
+import org.apache.fulcrum.security.entity.Role;
+import org.apache.fulcrum.security.torque.TorqueAbstractRoleManager;
+import org.apache.fulcrum.security.torque.peer.Peer;
+import org.apache.fulcrum.security.torque.peer.PeerManagable;
+import org.apache.fulcrum.security.torque.peer.PeerManager;
+import org.apache.fulcrum.security.torque.peer.TorqueTurbinePeer;
+import org.apache.fulcrum.security.util.DataBackendException;
+import org.apache.torque.NoRowsException;
+import org.apache.torque.TooManyRowsException;
+import org.apache.torque.TorqueException;
+import org.apache.torque.criteria.Criteria;
+
+import ${package}.om.TurbineRolePeer;
+/**
+ * This implementation persists to a database via Torque.
+ *
+ * @author <a href="mailto:[email protected]";>Thomas Vandahl</a>
+ * @version $Id:$
+ */
+public class TorqueTurbineRoleManagerImpl extends TorqueAbstractRoleManager 
implements PeerManagable
+{
+    PeerManager peerManager;
+    
+    /**
+     * @see 
org.apache.fulcrum.security.torque.TorqueAbstractRoleManager#doSelectAllRoles(java.sql.Connection)
+     */
+    @Override
+       @SuppressWarnings("unchecked")
+       protected <T extends Role> List<T> doSelectAllRoles(Connection con) 
throws TorqueException
+    {
+        Criteria criteria = new Criteria(TurbineRolePeer.DATABASE_NAME);
+
+        if ( (getCustomPeer())) {
+            try
+            {
+                return ((TorqueTurbinePeer<T>) getPeerInstance()).doSelect( 
criteria, con );
+            }
+            catch ( DataBackendException e )
+            {
+                throw new TorqueException( e );
+            }
+        } else {
+            return (List<T>) TurbineRolePeer.doSelect(criteria, con);
+        }
+    }
+
+    /**
+     * @see 
org.apache.fulcrum.security.torque.TorqueAbstractRoleManager#doSelectById(java.lang.Integer,
 java.sql.Connection)
+     */
+    @Override
+       @SuppressWarnings("unchecked")
+       protected <T extends Role> T doSelectById(Integer id, Connection con) 
throws NoRowsException, TooManyRowsException, TorqueException
+    {
+        if ( (getCustomPeer())) {
+            try
+            {
+                return ((TorqueTurbinePeer<T>) 
getPeerInstance()).retrieveByPK( id, con );
+            }
+            catch ( DataBackendException e )
+            {
+                throw new TorqueException( e );
+            }
+        } else {
+            return  (T)  TurbineRolePeer.retrieveByPK(id, con);
+        }
+    }
+
+    /**
+     * @see 
org.apache.fulcrum.security.torque.TorqueAbstractRoleManager#doSelectByName(java.lang.String,
 java.sql.Connection)
+     */
+    @Override
+       @SuppressWarnings("unchecked")
+       protected <T extends Role> T doSelectByName(String name, Connection 
con) throws NoRowsException, TooManyRowsException, TorqueException
+    {
+        Criteria criteria = new Criteria(TurbineRolePeer.DATABASE_NAME);
+        criteria.where(TurbineRolePeer.ROLE_NAME, name);
+        criteria.setIgnoreCase(true);
+        criteria.setSingleRecord(true);
+        
+        List<T> roles = null;
+        if ( (getCustomPeer())) {
+            try
+            {
+                roles = ((TorqueTurbinePeer<T>)getPeerInstance()).doSelect( 
criteria, con );
+            }
+            catch ( DataBackendException e )
+            {
+                throw new TorqueException( e );
+            }
+        } else {
+            roles =  (List<T>) TurbineRolePeer.doSelect(criteria, con);
+        }
+
+        if (roles.isEmpty())
+        {
+            throw new NoRowsException(name);
+        }
+
+        return roles.get(0);
+    }
+    
+    public Peer getPeerInstance() throws DataBackendException {
+        return getPeerManager().getPeerInstance(getPeerClassName(), 
TorqueTurbinePeer.class, getClassName());
+    }
+    
+    /**
+     * @return Returns the persistenceHelper.
+     */
+    @Override
+       public PeerManager getPeerManager()
+    {
+        if (peerManager == null)
+        {
+            peerManager = (PeerManager) resolve(PeerManager.ROLE);
+        }
+        return peerManager;
+    }
+}

Propchange: 
turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/src/main/java/fulcrum/security/torque/turbine/TorqueTurbineRoleManagerImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/src/main/java/fulcrum/security/torque/turbine/TorqueTurbineUserManagerImpl.java
URL: 
http://svn.apache.org/viewvc/turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/src/main/java/fulcrum/security/torque/turbine/TorqueTurbineUserManagerImpl.java?rev=1767705&view=auto
==============================================================================
--- 
turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/src/main/java/fulcrum/security/torque/turbine/TorqueTurbineUserManagerImpl.java
 (added)
+++ 
turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/src/main/java/fulcrum/security/torque/turbine/TorqueTurbineUserManagerImpl.java
 Wed Nov  2 15:23:30 2016
@@ -0,0 +1,200 @@
+package ${package}.fulcrum.security.torque.turbine;
+#*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements.  See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership.  The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License.  You may obtain a copy of the License at
+*
+*   http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied.  See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*#
+import java.sql.Connection;
+import java.util.List;
+
+import org.apache.fulcrum.security.entity.User;
+import org.apache.fulcrum.security.model.turbine.TurbineUserManager;
+
+import ${package}.fulcrum.security.torque.TorqueAbstractUserManager;
+
+import org.apache.fulcrum.security.torque.om.TorqueTurbineUserPeer;
+import org.apache.fulcrum.security.torque.peer.Peer;
+import org.apache.fulcrum.security.torque.peer.PeerManagable;
+import org.apache.fulcrum.security.torque.peer.PeerManager;
+import org.apache.fulcrum.security.torque.peer.TorqueTurbinePeer;
+import org.apache.fulcrum.security.util.DataBackendException;
+import org.apache.fulcrum.security.util.UnknownEntityException;
+import org.apache.torque.NoRowsException;
+import org.apache.torque.TooManyRowsException;
+import org.apache.torque.TorqueException;
+import org.apache.torque.criteria.Criteria;
+
+import ${package}.om.TurbineUserPeer;
+import ${package}.om.TurbineUserPeerImpl;
+
+/**
+ * This implementation persists to a database via Torque.
+ * 
+ *
+ * @author <a href="mailto:[email protected]";>Thomas Vandahl</a>
+ * @version $Id$
+ */
+public class TorqueTurbineUserManagerImpl extends TorqueAbstractUserManager 
implements TurbineUserManager, PeerManagable
+{
+    PeerManager peerManager;
+    private static final String ANON = "anon";
+
+    /**
+     * @see 
org.apache.fulcrum.security.torque.TorqueAbstractUserManager#doSelectAllUsers(java.sql.Connection)
+     */
+    @Override
+       @SuppressWarnings("unchecked")
+       protected <T extends User> List<T> doSelectAllUsers(Connection con) 
throws TorqueException
+    {
+        Criteria criteria = new Criteria();
+        
+        if ( (getCustomPeer())) {
+            try
+            {
+                return ((TorqueTurbinePeer<T>) getPeerInstance()).doSelect( 
criteria, con );
+            }
+            catch ( DataBackendException e )
+            {
+                throw new TorqueException( e );
+            }
+        } else {
+            return (List<T>) TorqueTurbineUserPeer.doSelect(criteria, con);
+        }
+    }
+
+    /**
+     * @see 
org.apache.fulcrum.security.torque.TorqueAbstractUserManager#doSelectById(java.lang.Integer,
 java.sql.Connection)
+     */
+    @Override
+       @SuppressWarnings("unchecked")
+       protected <T extends User> T doSelectById(Integer id, Connection con) 
throws NoRowsException, TooManyRowsException, TorqueException
+    {
+        if ( (getCustomPeer())) {
+            try
+            {
+                return ((TorqueTurbinePeer<T>) 
getPeerInstance()).retrieveByPK( id, con );
+            }
+            catch ( DataBackendException e )
+            {
+                throw new TorqueException( e );
+            }
+        } else {
+            return  (T)  TorqueTurbineUserPeer.retrieveByPK(id, con);
+        }
+    }
+
+    /**
+     * @see 
org.apache.fulcrum.security.torque.TorqueAbstractUserManager#doSelectByName(java.lang.String,
 java.sql.Connection)
+     */
+    @Override
+       @SuppressWarnings("unchecked")
+       protected <T extends User> T doSelectByName(String name, Connection 
con) throws NoRowsException, TooManyRowsException, TorqueException
+    {
+        Criteria criteria = new Criteria();
+        criteria.setIgnoreCase(true);
+        //criteria.setSingleRecord(true);
+        
+        List<T> users = null;
+        if ( (getCustomPeer())) {
+            try
+            {
+              System.out.println("criteria dbname is "+  criteria.getDbName());
+              TorqueTurbinePeer<T> peerInstance = 
(TorqueTurbinePeer<T>)getPeerInstance();
+              criteria.where( 
+                       TurbineUserPeer.LOGIN_NAME,
+                  name);
+              System.out.println("peerInstance is "+  peerInstance);
+              System.out.println("databae is "+  
((TurbineUserPeerImpl)peerInstance).getDatabaseName());
+
+              System.out.println("checkuser is "+  criteria.toString());
+              users = peerInstance.doSelect( criteria, con );
+            }
+            catch ( DataBackendException e )
+            {
+                throw new TorqueException( e );
+            }
+        } else {
+            //users = (List<T>) TorqueTurbineUserPeer.doSelect(criteria, con);
+        }
+
+         System.out.println("users is "+  users);
+
+        if (users.isEmpty())
+        {
+            throw new NoRowsException(name);
+        }
+
+        System.out.println("user is "+  users.get(0));
+        return users.get(0);
+    }
+
+    /**
+     * Default implementation.
+     */
+    @Override
+    public <T extends User> T getAnonymousUser()
+        throws UnknownEntityException
+    {
+        try
+        {
+            T anonUser =  getUser( ANON );
+            // add more, if needed
+            return anonUser;
+        }
+        catch ( DataBackendException e )
+        {
+            throw new UnknownEntityException( "Failed to load anonymous 
user",e);
+        } 
+    }
+
+    /**
+     * Default implementation.
+     */
+    @Override
+    public boolean isAnonymousUser( User u )
+    {
+        try
+        {
+            User anon = getAnonymousUser();
+            if (u.equals( anon )) 
+                {
+                 return true;
+                }
+        }
+        catch ( Exception e )
+        {
+            getLogger().error( "Failed to check user:" + e.getMessage(),e);
+        }
+        return false;
+    }
+    
+    public Peer getPeerInstance() throws DataBackendException {
+        return getPeerManager().getPeerInstance(getPeerClassName(), 
TorqueTurbinePeer.class, getClassName());
+    }
+    
+    /**
+     * @return Returns the persistenceHelper.
+     */
+    @Override
+    public PeerManager getPeerManager()
+    {
+        if (peerManager == null)
+        {
+            peerManager = (PeerManager) resolve(PeerManager.ROLE);
+        }
+        return peerManager;
+    }
+}

Propchange: 
turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/src/main/java/fulcrum/security/torque/turbine/TorqueTurbineUserManagerImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native


Reply via email to