- cleanup using new security snapshot in archetype-resources/pom.xml
- no dependency to local fulcrum, cft. also torque-security-schema.xml and roleConfiguration.xml
- TODO remove SNAPSHOT in archetype pom after releasing fulcrum security
git-svn-id: https://svn.apache.org/repos/asf/turbine/maven/archetypes/trunk/turbine-webapp-4.0@1794574 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/src/main/resources/archetype-resources/pom.xml b/src/main/resources/archetype-resources/pom.xml
index 1ddf81d..e4e7bf2 100644
--- a/src/main/resources/archetype-resources/pom.xml
+++ b/src/main/resources/archetype-resources/pom.xml
@@ -239,68 +239,76 @@
<groupId>mysql</groupId>
<version>5.1.40</version>
</dependency>
- <dependency>
- <groupId>javax.activation</groupId>
- <artifactId>activation</artifactId>
- <version>1.1.1</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>javax.mail</groupId>
- <artifactId>mail</artifactId>
- <version>1.4.5</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>javax.servlet</groupId>
- <artifactId>servlet-api</artifactId>
- <version>2.5</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.turbine</groupId>
- <artifactId>turbine</artifactId>
- <version>4.0-SNAPSHOT</version>
- </dependency>
- <!-- yaafi is optional. NOTICE: 1.0.7 has group org.apache.turbine not org.apache.fulcrum -->
- <dependency>
+ <dependency>
+ <groupId>javax.activation</groupId>
+ <artifactId>activation</artifactId>
+ <version>1.1.1</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.mail</groupId>
+ <artifactId>mail</artifactId>
+ <version>1.4.5</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.5</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
<groupId>org.apache.turbine</groupId>
- <artifactId>fulcrum-yaafi</artifactId>
- <version>1.0.7</version>
- </dependency>
- <!-- if using intake -->
- <dependency>
- <groupId>org.apache.fulcrum</groupId>
- <artifactId>fulcrum-intake</artifactId>
- <version>1.2.2</version>
- </dependency>
- <!-- include some optional dependencies required in example componentConfiguration.xml -->
- <dependency>
- <groupId>org.apache.fulcrum</groupId>
- <artifactId>fulcrum-cache</artifactId>
- <version>1.1.0</version>
- </dependency>
- <dependency>
- <groupId>org.apache.fulcrum</groupId>
- <artifactId>fulcrum-upload</artifactId>
- <version>1.0.5</version>
- </dependency>
- <dependency>
- <groupId>org.apache.fulcrum</groupId>
- <artifactId>fulcrum-security-memory</artifactId>
- <version>1.1.0</version>
- </dependency>
- <dependency>
- <groupId>org.apache.fulcrum</groupId>
- <artifactId>fulcrum-security-torque</artifactId>
- <version>1.1.0</version>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>4.12</version>
- <scope>test</scope>
- </dependency>
+ <artifactId>turbine</artifactId>
+ <version>4.0-SNAPSHOT</version>
+ </dependency>
+ <!-- yaafi is optional. NOTICE: 1.0.7 has group org.apache.turbine not org.apache.fulcrum -->
+ <dependency>
+ <groupId>org.apache.turbine</groupId>
+ <artifactId>fulcrum-yaafi</artifactId>
+ <version>1.0.7</version>
+ </dependency>
+ <!-- if using intake -->
+ <dependency>
+ <groupId>org.apache.fulcrum</groupId>
+ <artifactId>fulcrum-intake</artifactId>
+ <version>1.2.2</version>
+ </dependency>
+ <!-- include some optional dependencies required in example componentConfiguration.xml -->
+ <dependency>
+ <groupId>org.apache.fulcrum</groupId>
+ <artifactId>fulcrum-cache</artifactId>
+ <version>1.1.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.fulcrum</groupId>
+ <artifactId>fulcrum-upload</artifactId>
+ <version>1.0.5</version>
+ </dependency>
+ <!-- using snapshot, until released -->
+ <dependency>
+ <groupId>org.apache.fulcrum</groupId>
+ <artifactId>fulcrum-security-memory</artifactId>
+ <version>1.1.1-SNAPSHOT</version>
+ </dependency>
+ <!-- using snapshot, until released -->
+ <dependency>
+ <groupId>org.apache.fulcrum</groupId>
+ <artifactId>fulcrum-security-torque</artifactId>
+ <version>1.1.1-SNAPSHOT</version>
+ </dependency>
+ <!-- using snapshots, could be removed if turbine is updated fro 1.1.0 to 1.1.1 -->
+ <dependency>
+ <groupId>org.apache.fulcrum</groupId>
+ <artifactId>fulcrum-security-api</artifactId>
+ <version>1.1.1-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.12</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<properties>
diff --git a/src/main/resources/archetype-resources/src/main/java/fulcrum/security/torque/TorqueAbstractUserManager.java b/src/main/resources/archetype-resources/src/main/java/fulcrum/security/torque/TorqueAbstractUserManager.java
deleted file mode 100644
index 5509438..0000000
--- a/src/main/resources/archetype-resources/src/main/java/fulcrum/security/torque/TorqueAbstractUserManager.java
+++ /dev/null
@@ -1,400 +0,0 @@
-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:tv@apache.org">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;
- }
-
-}
diff --git a/src/main/resources/archetype-resources/src/main/java/fulcrum/security/torque/turbine/TorqueAbstractTurbineGroup.java b/src/main/resources/archetype-resources/src/main/java/fulcrum/security/torque/turbine/TorqueAbstractTurbineGroup.java
deleted file mode 100644
index f4413a5..0000000
--- a/src/main/resources/archetype-resources/src/main/java/fulcrum/security/torque/turbine/TorqueAbstractTurbineGroup.java
+++ /dev/null
@@ -1,141 +0,0 @@
-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.
-* #set( $H = '#' )
-*#
-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:tv@apache.org">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$HgetDatabaseName()
- */
- @Override
- public String getDatabaseName()
- {
- return TurbineGroupPeer.DATABASE_NAME;
- }
-
- /**
- * @see org.apache.fulcrum.security.torque.TorqueAbstractSecurityEntity$HretrieveAttachedObjects(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$Hupdate(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$Hdelete()
- */
- @Override
- public void delete() throws TorqueException
- {
- TurbineGroupPeer.doDelete(SimpleKey.keyFor(getEntityId()));
- }
-}
diff --git a/src/main/resources/archetype-resources/src/main/java/fulcrum/security/torque/turbine/TorqueAbstractTurbinePermission.java b/src/main/resources/archetype-resources/src/main/java/fulcrum/security/torque/turbine/TorqueAbstractTurbinePermission.java
deleted file mode 100644
index 5648f1f..0000000
--- a/src/main/resources/archetype-resources/src/main/java/fulcrum/security/torque/turbine/TorqueAbstractTurbinePermission.java
+++ /dev/null
@@ -1,207 +0,0 @@
-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.
- * #set( $H = '#' )
- * @author <a href="mailto:tv@apache.org">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$HaddRole(org.apache.fulcrum.security.entity.Role)
- */
- @Override
- public void addRole(Role role)
- {
- getRoles().add(role);
- }
-
- /**
- * @see org.apache.fulcrum.security.model.turbine.entity.TurbinePermission$HgetRoles()
- */
- @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$HgetRolesAsSet()
- */
- @Override
- @SuppressWarnings("unchecked")
- public <T extends Role> Set<T> getRolesAsSet()
- {
- return (Set<T>)roleSet;
- }
-
- /**
- * @see org.apache.fulcrum.security.model.turbine.entity.TurbinePermission$HremoveRole(org.apache.fulcrum.security.entity.Role)
- */
- @Override
- public void removeRole(Role role)
- {
- getRoles().remove(role);
- }
-
- /**
- * @see org.apache.fulcrum.security.model.turbine.entity.TurbinePermission$HsetRoles(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$HsetRolesAsSet(java.util.Set)
- */
- @Override
- public <T extends Role> void setRolesAsSet(Set<T> roles)
- {
- setRoles(new RoleSet(roles));
- }
-
- /**
- * @see org.apache.fulcrum.security.torque.TorqueAbstractSecurityEntity$HgetDatabaseName()
- */
- @Override
- public String getDatabaseName()
- {
- return TurbinePermissionPeer.DATABASE_NAME;
- }
-
- /**
- * @see org.apache.fulcrum.security.torque.TorqueAbstractSecurityEntity$HretrieveAttachedObjects(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$Hupdate(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$Hdelete()
- */
- @Override
- public void delete() throws TorqueException
- {
- TurbinePermissionPeer.doDelete(SimpleKey.keyFor(getEntityId()));
- }
-}
diff --git a/src/main/resources/archetype-resources/src/main/java/fulcrum/security/torque/turbine/TorqueAbstractTurbineRole.java b/src/main/resources/archetype-resources/src/main/java/fulcrum/security/torque/turbine/TorqueAbstractTurbineRole.java
deleted file mode 100644
index cc09076..0000000
--- a/src/main/resources/archetype-resources/src/main/java/fulcrum/security/torque/turbine/TorqueAbstractTurbineRole.java
+++ /dev/null
@@ -1,264 +0,0 @@
-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.
- * #set( $H = '#' )
- * @author <a href="mailto:tv@apache.org">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$HaddPermission(org.apache.fulcrum.security.entity.Permission)
- */
- @Override
- public void addPermission(Permission permission)
- {
- getPermissions().add(permission);
- }
-
- /**
- * @see org.apache.fulcrum.security.model.turbine.entity.TurbineRole$HgetPermissions()
- */
- @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$HgetPermissionsAsSet()
- */
- @Override
- @SuppressWarnings("unchecked")
- public <T extends Permission> Set<T> getPermissionsAsSet()
- {
- return (Set<T>)permissionSet;
- }
-
- /**
- * @see org.apache.fulcrum.security.model.turbine.entity.TurbineRole$HremovePermission(org.apache.fulcrum.security.entity.Permission)
- */
- @Override
- public void removePermission(Permission permission)
- {
- getPermissions().remove(permission);
- }
-
- /**
- * @see org.apache.fulcrum.security.model.turbine.entity.TurbineRole$HsetPermissions(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$HsetPermissionsAsSet(java.util.Set)
- */
- @Override
- public <T extends Permission> void setPermissionsAsSet(Set<T> permissions)
- {
- setPermissions(new PermissionSet(permissions));
- }
-
- /**
- * @see org.apache.fulcrum.security.torque.TorqueAbstractSecurityEntity$HgetDatabaseName()
- */
- @Override
- public String getDatabaseName()
- {
- return TurbineRolePeer.DATABASE_NAME;
- }
-
- /**
- * @see org.apache.fulcrum.security.torque.TorqueAbstractSecurityEntity$HretrieveAttachedObjects(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$Hupdate(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$Hdelete()
- */
- @Override
- public void delete() throws TorqueException
- {
- TurbineRolePeer.doDelete(SimpleKey.keyFor(getEntityId()));
- }
-}
diff --git a/src/main/resources/archetype-resources/src/main/java/fulcrum/security/torque/turbine/TorqueAbstractTurbineUser.java b/src/main/resources/archetype-resources/src/main/java/fulcrum/security/torque/turbine/TorqueAbstractTurbineUser.java
deleted file mode 100644
index c722341..0000000
--- a/src/main/resources/archetype-resources/src/main/java/fulcrum/security/torque/turbine/TorqueAbstractTurbineUser.java
+++ /dev/null
@@ -1,139 +0,0 @@
-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.
- * #set( $H = '#' )
- * @author <a href="mailto:tv@apache.org">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$HgetDatabaseName()
- */
- @Override
- public String getDatabaseName()
- {
- return TorqueTurbineUserPeer.DATABASE_NAME;
- }
-
- /**
- * @see org.apache.fulcrum.security.torque.TorqueAbstractSecurityEntity$HretrieveAttachedObjects(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$Hupdate(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$Hdelete()
- */
- @Override
- public void delete() throws TorqueException
- {
- TorqueTurbineUserPeer.doDelete(SimpleKey.keyFor(getEntityId()));
- }
-}
diff --git a/src/main/resources/archetype-resources/src/main/java/fulcrum/security/torque/turbine/TorqueTurbineGroupManagerImpl.java b/src/main/resources/archetype-resources/src/main/java/fulcrum/security/torque/turbine/TorqueTurbineGroupManagerImpl.java
deleted file mode 100644
index e07fbc0..0000000
--- a/src/main/resources/archetype-resources/src/main/java/fulcrum/security/torque/turbine/TorqueTurbineGroupManagerImpl.java
+++ /dev/null
@@ -1,144 +0,0 @@
-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.
- * #set( $H = '#' )
- * @author <a href="mailto:tv@apache.org">Thomas Vandahl</a>
- * @version $Id:$
- */
-public class TorqueTurbineGroupManagerImpl extends TorqueAbstractGroupManager implements PeerManagable
-{
-
- PeerManager peerManager;
- /**
- * @see org.apache.fulcrum.security.torque.TorqueAbstractGroupManager$HdoSelectAllGroups(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$HdoSelectById(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$HdoSelectByName(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;
- }
-}
diff --git a/src/main/resources/archetype-resources/src/main/java/fulcrum/security/torque/turbine/TorqueTurbineRoleManagerImpl.java b/src/main/resources/archetype-resources/src/main/java/fulcrum/security/torque/turbine/TorqueTurbineRoleManagerImpl.java
deleted file mode 100644
index 137d1f1..0000000
--- a/src/main/resources/archetype-resources/src/main/java/fulcrum/security/torque/turbine/TorqueTurbineRoleManagerImpl.java
+++ /dev/null
@@ -1,140 +0,0 @@
-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.
- * #set( $H = '#' )
- * @author <a href="mailto:tv@apache.org">Thomas Vandahl</a>
- * @version $Id:$
- */
-public class TorqueTurbineRoleManagerImpl extends TorqueAbstractRoleManager implements PeerManagable
-{
- PeerManager peerManager;
-
- /**
- * @see org.apache.fulcrum.security.torque.TorqueAbstractRoleManager$HdoSelectAllRoles(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$HdoSelectById(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$HdoSelectByName(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;
- }
-}
diff --git a/src/main/resources/archetype-resources/src/main/java/fulcrum/security/torque/turbine/TorqueTurbineUserManagerImpl.java b/src/main/resources/archetype-resources/src/main/java/fulcrum/security/torque/turbine/TorqueTurbineUserManagerImpl.java
deleted file mode 100644
index 36e567c..0000000
--- a/src/main/resources/archetype-resources/src/main/java/fulcrum/security/torque/turbine/TorqueTurbineUserManagerImpl.java
+++ /dev/null
@@ -1,199 +0,0 @@
-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.
- * #set( $H = '#' )
- * @author <a href="mailto:tv@apache.org">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$HdoSelectAllUsers(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$HdoSelectById(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$HdoSelectByName(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;
- }
-}
diff --git a/src/main/resources/archetype-resources/src/main/java/om/TurbineGroup.java b/src/main/resources/archetype-resources/src/main/java/om/TurbineGroup.java
index 51f3415..caefec3 100644
--- a/src/main/resources/archetype-resources/src/main/java/om/TurbineGroup.java
+++ b/src/main/resources/archetype-resources/src/main/java/om/TurbineGroup.java
@@ -79,10 +79,4 @@
setGroupId(id);
}
- @Override
- public String getDatabaseName()
- {
- return "default";
- }
-
}
diff --git a/src/main/resources/archetype-resources/src/main/java/om/TurbineRole.java b/src/main/resources/archetype-resources/src/main/java/om/TurbineRole.java
index aee193e..4445821 100644
--- a/src/main/resources/archetype-resources/src/main/java/om/TurbineRole.java
+++ b/src/main/resources/archetype-resources/src/main/java/om/TurbineRole.java
@@ -1,11 +1,6 @@
package ${package}.om;
-import java.sql.Connection;
-import java.util.Set;
-
-import org.apache.fulcrum.security.model.turbine.entity.TurbineUserGroupRole;
import org.apache.torque.TorqueException;
-import org.apache.torque.om.SimpleKey;
/**
@@ -63,37 +58,4 @@
setRoleId(id);
}
- /**
- * @TODO
- */
- @Override
- public void update(Connection con) throws TorqueException {
- Set<TurbineUserGroupRole> userGroupRoleSet = getUserGroupRoleSet();
- if (userGroupRoleSet != null)
- {
-
-
- }
-
- try
- {
- save(con);
- }
- catch (Exception e)
- {
- throw new TorqueException(e);
- }
- }
-
- @Override
- public String getDatabaseName() {
- return "default";
- }
-
- @Override
- public void delete() throws TorqueException {
- TurbineRolePeer.doDelete(SimpleKey.keyFor(getEntityId()));
-
- }
-
}
diff --git a/src/main/resources/archetype-resources/src/main/java/om/TurbineUser.java b/src/main/resources/archetype-resources/src/main/java/om/TurbineUser.java
index 0d7b6f1..5416761 100644
--- a/src/main/resources/archetype-resources/src/main/java/om/TurbineUser.java
+++ b/src/main/resources/archetype-resources/src/main/java/om/TurbineUser.java
@@ -7,8 +7,6 @@
import org.apache.fulcrum.security.model.turbine.entity.TurbineUserGroupRole;
import org.apache.torque.TorqueException;
-import org.apache.torque.criteria.Criteria;
-import org.apache.torque.om.SimpleKey;
/**
@@ -79,15 +77,6 @@
}
/**
- * @see org.apache.fulcrum.security.torque.TorqueAbstractSecurityEntity$HgetDatabaseName()
- */
- @Override
- public String getDatabaseName()
- {
- return "default";
- }
-
- /**
* @see org.apache.fulcrum.security.torque.TorqueAbstractSecurityEntity$HretrieveAttachedObjects(java.sql.Connection)
*/
@Override
@@ -95,7 +84,7 @@
{
Set<TurbineUserGroupRole> userGroupRoleSet = new HashSet<TurbineUserGroupRole>();
- List<${package}.om.TurbineUserGroupRole> ugrs = getTurbineUserGroupRolesJoinTurbineUser(new Criteria(), con);
+ List<${package}.om.TurbineUserGroupRole> ugrs = getTurbineUserGroupRoles();
for (${package}.om.TurbineUserGroupRole ttugr : ugrs)
{
@@ -109,40 +98,4 @@
setUserGroupRoleSet(userGroupRoleSet);
}
- /**
- * @see org.apache.fulcrum.security.torque.TorqueAbstractSecurityEntity$Hupdate(java.sql.Connection)
- *
- * @TODO
- */
- @Override
- public void update(Connection con) throws TorqueException
- {
- Set<TurbineUserGroupRole> userGroupRoleSet = getUserGroupRoleSet();
- if (userGroupRoleSet != null)
- {
-
-
- }
-
- try
- {
- save(con);
- }
- catch (Exception e)
- {
- throw new TorqueException(e);
- }
- }
-
- /**
- * @see org.apache.fulcrum.security.torque.TorqueAbstractSecurityEntity$Hdelete()
- */
- @Override
- public void delete() throws TorqueException
- {
- TurbineUserPeer.doDelete(SimpleKey.keyFor(getEntityId()));
- }
-
-
-
}
diff --git a/src/main/resources/archetype-resources/src/main/torque-schema/torque-security-schema.xml b/src/main/resources/archetype-resources/src/main/torque-schema/torque-security-schema.xml
index 84cbd6b..113369c 100644
--- a/src/main/resources/archetype-resources/src/main/torque-schema/torque-security-schema.xml
+++ b/src/main/resources/archetype-resources/src/main/torque-schema/torque-security-schema.xml
@@ -35,7 +35,7 @@
defaultIdMethod="idbroker">
- <table name="TURBINE_PERMISSION" idMethod="idbroker" baseClass="${package}.fulcrum.security.torque.turbine.TorqueAbstractTurbinePermission">
+ <table name="TURBINE_PERMISSION" idMethod="idbroker" baseClass="org.apache.fulcrum.security.torque.turbine.DefaultAbstractTurbinePermission">
<column name="PERMISSION_ID" required="true" primaryKey="true" type="INTEGER" javaType="object"/>
<column name="PERMISSION_NAME" required="true" size="64" type="VARCHAR" javaName="EntityName"/>
@@ -45,7 +45,7 @@
</table>
- <table name="TURBINE_ROLE" idMethod="idbroker" baseClass="${package}.fulcrum.security.torque.turbine.TorqueAbstractTurbineRole">
+ <table name="TURBINE_ROLE" idMethod="idbroker" baseClass="org.apache.fulcrum.security.torque.turbine.DefaultAbstractTurbineRole">
<column name="ROLE_ID" required="true" primaryKey="true" type="INTEGER" javaType="object"/>
<column name="ROLE_NAME" required="true" size="64" type="VARCHAR" javaName="EntityName"/>
@@ -55,7 +55,7 @@
</table>
- <table name="TURBINE_GROUP" idMethod="idbroker" baseClass="${package}.fulcrum.security.torque.turbine.TorqueAbstractTurbineGroup">
+ <table name="TURBINE_GROUP" idMethod="idbroker" baseClass="org.apache.fulcrum.security.torque.turbine.DefaultAbstractTurbineGroup">
<column name="GROUP_ID" required="true" primaryKey="true" type="INTEGER" javaType="object"/>
<column name="GROUP_NAME" required="true" type="VARCHAR" size="64" javaName="EntityName"/>
@@ -79,7 +79,7 @@
</table>
<!-- org.apache.fulcrum.security.torque.TorqueAbstractSecurityEntity -->
- <table name="TURBINE_USER" idMethod="idbroker" baseClass="org.apache.fulcrum.security.torque.turbine.TorqueAbstractTurbineTurbineSecurityEntity"
+ <table name="TURBINE_USER" idMethod="idbroker" baseClass="org.apache.fulcrum.security.torque.turbine.DefaultAbstractTurbineUser"
interface="org.apache.fulcrum.security.model.turbine.entity.TurbineUser">
<column name="USER_ID" required="true" primaryKey="true" type="INTEGER" javaType="object" javaName="EntityId"/>
<column name="LOGIN_NAME" required="true" size="64" type="VARCHAR" javaName="EntityName"/>
diff --git a/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/conf/roleConfiguration.xml b/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/conf/roleConfiguration.xml
index a0886a4..85d4f1c 100644
--- a/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/conf/roleConfiguration.xml
+++ b/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/conf/roleConfiguration.xml
@@ -85,22 +85,22 @@
name="org.apache.fulcrum.security.UserManager"
shorthand="userManager"
early-init="true"
- default-class="${package}.fulcrum.security.torque.turbine.TorqueTurbineUserManagerImpl"/>
+ default-class="org.apache.fulcrum.security.torque.turbine.TorqueTurbineUserManagerImpl"/>
<role
name="org.apache.fulcrum.security.GroupManager"
shorthand="groupManager"
- default-class="${package}.fulcrum.security.torque.turbine.TorqueTurbineGroupManagerImpl"/>
+ default-class="org.apache.fulcrum.security.torque.turbine.TorqueTurbineGroupManagerImpl"/>
<role
name="org.apache.fulcrum.security.RoleManager"
shorthand="roleManager"
- default-class="${package}.fulcrum.security.torque.turbine.TorqueTurbineRoleManagerImpl"/>
+ default-class="org.apache.fulcrum.security.torque.turbine.TorqueTurbineRoleManagerImpl"/>
<role
name="org.apache.fulcrum.security.PermissionManager"
shorthand="permissionManager"
- default-class="org.apache.fulcrum.security.memory.MemoryPermissionManagerImpl"/>
+ default-class="org.apache.fulcrum.security.torque.turbine.TorqueTurbinePermissionManagerImpl"/>
<role
name="org.apache.fulcrum.security.torque.peer.PeerManager"
@@ -134,7 +134,7 @@
<role
name="org.apache.fulcrum.security.ModelManager"
shorthand="modelManager"
- default-class="org.apache.fulcrum.security.memory.turbine.MemoryTurbineModelManagerImpl"/>
+ default-class="org.apache.fulcrum.security.torque.turbine.TorqueTurbineModelManagerImpl"/>
<role
name="org.apache.fulcrum.security.authenticator.Authenticator"
@@ -146,28 +146,6 @@
shorthand="aclFactory"
default-class="org.apache.fulcrum.security.model.turbine.TurbineACLFactory"/>
- <!-- use torque managers for database mysql et al. -->
- <!-- <role
- name="org.apache.fulcrum.security.UserManager"
- shorthand="userManager"
- early-init="true"
- default-class="org.apache.fulcrum.security.torque.turbine.TorqueTurbineUserManagerImpl"/>
- <role
- name="org.apache.fulcrum.security.GroupManager"
- shorthand="groupManager"
- default-class="org.apache.fulcrum.security.torque.turbine.TorqueTurbineGroupManagerImpl"/>
- <role
- name="org.apache.fulcrum.security.RoleManager"
- shorthand="roleManager"
- default-class="org.apache.fulcrum.security.torque.turbine.TorqueTurbineRoleManagerImpl"/>
- <role
- name="org.apache.fulcrum.security.PermissionManager"
- shorthand="permissionManager"
- default-class="org.apache.fulcrum.security.torque.turbine.TorqueTurbinePermissionManagerImpl"/>
- <role
- name="org.apache.fulcrum.security.ModelManager"
- shorthand="modelManager"
- default-class="org.apache.fulcrum.security.torque.turbine.TorqueTurbineModelManagerImpl"/-->
<!-- role
name="org.apache.fulcrum.json.JsonService"