Coverage report

  %line %branch
org.apache.turbine.services.security.torque.UserPeerManager
34% 
68% 

 1  
 package org.apache.turbine.services.security.torque;
 2  
 
 3  
 /*
 4  
  * Copyright 2001-2005 The Apache Software Foundation.
 5  
  *
 6  
  * Licensed under the Apache License, Version 2.0 (the "License")
 7  
  * you may not use this file except in compliance with the License.
 8  
  * You may obtain a copy of the License at
 9  
  *
 10  
  *     http://www.apache.org/licenses/LICENSE-2.0
 11  
  *
 12  
  * Unless required by applicable law or agreed to in writing, software
 13  
  * distributed under the License is distributed on an "AS IS" BASIS,
 14  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 15  
  * See the License for the specific language governing permissions and
 16  
  * limitations under the License.
 17  
  */
 18  
 
 19  
 import java.beans.PropertyDescriptor;
 20  
 
 21  
 import java.util.ArrayList;
 22  
 import java.util.Iterator;
 23  
 import java.util.List;
 24  
 
 25  
 import org.apache.commons.configuration.Configuration;
 26  
 
 27  
 import org.apache.commons.logging.Log;
 28  
 import org.apache.commons.logging.LogFactory;
 29  
 
 30  
 import org.apache.torque.TorqueException;
 31  
 import org.apache.torque.om.Persistent;
 32  
 import org.apache.torque.util.BasePeer;
 33  
 import org.apache.torque.util.Criteria;
 34  
 
 35  
 import org.apache.turbine.om.security.User;
 36  
 import org.apache.turbine.services.InitializationException;
 37  
 import org.apache.turbine.services.security.TurbineSecurity;
 38  
 import org.apache.turbine.util.security.DataBackendException;
 39  
 
 40  
 /**
 41  
  * This class capsulates all direct Peer access for the User entities.
 42  
  * It allows the exchange of the default Turbine supplied TurbineUserPeer
 43  
  * class against a custom class.
 44  
  *
 45  
  * @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a>
 46  
  * @version $Id: UserPeerManager.java 264152 2005-08-29 14:50:22Z henning $
 47  
  */
 48  
 
 49  18
 public class UserPeerManager
 50  
     implements UserPeerManagerConstants
 51  
 {
 52  
     /** Serial UID */
 53  
     private static final long serialVersionUID = 6943046259921811593L;
 54  
 
 55  
     /** The class of the Peer the TorqueSecurityService uses */
 56  24
     private static Class userPeerClass = null;
 57  
 
 58  
     /** The class name of the objects returned by the configured peer. */
 59  16
     private static Class userObject = null;
 60  
 
 61  
     /** The name of the Table used for Group Object queries  */
 62  16
     private static String tableName = null;
 63  
 
 64  
     /** The name of the column used as "Name" Column */
 65  16
     private static String nameColumn = null;
 66  
 
 67  
     /** The name of the column used as "Id" Column */
 68  16
     private static String idColumn = null;
 69  
 
 70  
     /** The name of the column used as "Password" Column */
 71  16
     private static String passwordColumn = null;
 72  
 
 73  
     /** The name of the column used as "First name" Column */
 74  16
     private static String firstNameColumn = null;
 75  
 
 76  
     /** The name of the column used as "Last name" Column */
 77  16
     private static String lastNameColumn = null;
 78  
 
 79  
     /** The name of the column used as "Email" Column */
 80  16
     private static String emailColumn = null;
 81  
 
 82  
     /** The name of the column used as "Confirm" Column */
 83  16
     private static String confirmColumn = null;
 84  
 
 85  
     /** The name of the column used as "create date" Column */
 86  16
     private static String createDateColumn = null;
 87  
 
 88  
     /** The name of the column used as "last login" Column */
 89  16
     private static String lastLoginColumn = null;
 90  
 
 91  
     /** The name of the column used as "objectdata" Column */
 92  16
     private static String objectdataColumn = null;
 93  
 
 94  
     /** The "Name" property descriptor */
 95  16
     private static PropertyDescriptor namePropDesc = null;
 96  
 
 97  
     /** The "Id" property descriptor */
 98  16
     private static PropertyDescriptor idPropDesc = null;
 99  
 
 100  
     /** The "Password" property descriptor */
 101  16
     private static PropertyDescriptor passwordPropDesc = null;
 102  
 
 103  
     /** The "First name" property descriptor */
 104  16
     private static PropertyDescriptor firstNamePropDesc = null;
 105  
 
 106  
     /** The "Last name" property descriptor */
 107  16
     private static PropertyDescriptor lastNamePropDesc = null;
 108  
 
 109  
     /** The "Email" property descriptor */
 110  16
     private static PropertyDescriptor emailPropDesc = null;
 111  
 
 112  
     /** The "Confirm" property descriptor */
 113  16
     private static PropertyDescriptor confirmPropDesc = null;
 114  
 
 115  
     /** The "create date" property descriptor */
 116  16
     private static PropertyDescriptor createDatePropDesc = null;
 117  
 
 118  
     /** The "last login" property descriptor */
 119  16
     private static PropertyDescriptor lastLoginPropDesc = null;
 120  
 
 121  
     /** The "objectdata" property descriptor */
 122  16
     private static PropertyDescriptor objectdataPropDesc = null;
 123  
 
 124  
     /** Logging */
 125  34
     static Log log = LogFactory.getLog(UserPeerManager.class);
 126  
 
 127  
     /**
 128  
      * Initializes the UserPeerManager, loading the class object for the
 129  
      * Peer used to retrieve User objects
 130  
      *
 131  
      * @param conf The configuration object used to configure the Manager
 132  
      *
 133  
      * @exception InitializationException A problem occured during
 134  
      *            initialization
 135  
      */
 136  
 
 137  
     public static void init(Configuration conf)
 138  
         throws InitializationException
 139  
     {
 140  16
         String userPeerClassName = conf.getString(USER_PEER_CLASS_KEY,
 141  
                                                   USER_PEER_CLASS_DEFAULT);
 142  16
         String userObjectName = null;
 143  
 
 144  
         try
 145  
         {
 146  16
             userPeerClass = Class.forName(userPeerClassName);
 147  
 
 148  16
             tableName  =
 149  
               (String) userPeerClass.getField("TABLE_NAME").get(null);
 150  
 
 151  
             //
 152  
             // We have either an user configured Object class or we use the
 153  
             // default as supplied by the Peer class
 154  
             //
 155  
 
 156  
             // Default from Peer, can be overridden
 157  
 
 158  16
             userObject = getPersistenceClass();
 159  
 
 160  16
             userObjectName = conf.getString(USER_CLASS_KEY,
 161  
                     userObject.getName());
 162  
 
 163  
             // Maybe the user set a new value...
 164  16
             userObject = Class.forName(userObjectName);
 165  
 
 166  
             /* If any of the following Field queries fails, the user
 167  
              * subsystem is unusable. So check this right here at init time,
 168  
              * which saves us much time and hassle if it fails...
 169  
              */
 170  
 
 171  16
             nameColumn = (String) userPeerClass.getField(
 172  
                 conf.getString(USER_NAME_COLUMN_KEY,
 173  
                                USER_NAME_COLUMN_DEFAULT)
 174  
                 ).get(null);
 175  
 
 176  16
             idColumn = (String) userPeerClass.getField(
 177  
                 conf.getString(USER_ID_COLUMN_KEY,
 178  
                                USER_ID_COLUMN_DEFAULT)
 179  
                 ).get(null);
 180  
 
 181  16
             passwordColumn = (String) userPeerClass.getField(
 182  
                 conf.getString(USER_PASSWORD_COLUMN_KEY,
 183  
                                USER_PASSWORD_COLUMN_DEFAULT)
 184  
                 ).get(null);
 185  
 
 186  16
             firstNameColumn  = (String) userPeerClass.getField(
 187  
                 conf.getString(USER_FIRST_NAME_COLUMN_KEY,
 188  
                                USER_FIRST_NAME_COLUMN_DEFAULT)
 189  
                 ).get(null);
 190  
 
 191  16
             lastNameColumn = (String) userPeerClass.getField(
 192  
                 conf.getString(USER_LAST_NAME_COLUMN_KEY,
 193  
                                USER_LAST_NAME_COLUMN_DEFAULT)
 194  
                 ).get(null);
 195  
 
 196  16
             emailColumn = (String) userPeerClass.getField(
 197  
                 conf.getString(USER_EMAIL_COLUMN_KEY,
 198  
                                USER_EMAIL_COLUMN_DEFAULT)
 199  
                 ).get(null);
 200  
 
 201  16
             confirmColumn    = (String) userPeerClass.getField(
 202  
                 conf.getString(USER_CONFIRM_COLUMN_KEY,
 203  
                                USER_CONFIRM_COLUMN_DEFAULT)
 204  
                 ).get(null);
 205  
 
 206  16
             createDateColumn = (String) userPeerClass.getField(
 207  
                 conf.getString(USER_CREATE_COLUMN_KEY,
 208  
                                USER_CREATE_COLUMN_DEFAULT)
 209  
                 ).get(null);
 210  
 
 211  16
             lastLoginColumn = (String) userPeerClass.getField(
 212  
                 conf.getString(USER_LAST_LOGIN_COLUMN_KEY,
 213  
                                USER_LAST_LOGIN_COLUMN_DEFAULT)
 214  
                 ).get(null);
 215  
 
 216  16
             objectdataColumn = (String) userPeerClass.getField(
 217  
                 conf.getString(USER_OBJECTDATA_COLUMN_KEY,
 218  
                                USER_OBJECTDATA_COLUMN_DEFAULT)
 219  
                 ).get(null);
 220  
 
 221  16
             namePropDesc =
 222  
                 new PropertyDescriptor(conf.getString(
 223  
                                            USER_NAME_PROPERTY_KEY,
 224  
                                            USER_NAME_PROPERTY_DEFAULT),
 225  
                                        userObject);
 226  
 
 227  16
             idPropDesc =
 228  
                 new PropertyDescriptor(conf.getString(
 229  
                                            USER_ID_PROPERTY_KEY,
 230  
                                            USER_ID_PROPERTY_DEFAULT),
 231  
                                        userObject);
 232  
 
 233  16
             passwordPropDesc =
 234  
                 new PropertyDescriptor(conf.getString(
 235  
                                            USER_PASSWORD_PROPERTY_KEY,
 236  
                                            USER_PASSWORD_PROPERTY_DEFAULT),
 237  
                                        userObject);
 238  
 
 239  16
             firstNamePropDesc =
 240  
                 new PropertyDescriptor(conf.getString(
 241  
                                            USER_FIRST_NAME_PROPERTY_KEY,
 242  
                                            USER_FIRST_NAME_PROPERTY_DEFAULT),
 243  
                                        userObject);
 244  
 
 245  16
             lastNamePropDesc   =
 246  
                 new PropertyDescriptor(conf.getString(
 247  
                                            USER_LAST_NAME_PROPERTY_KEY,
 248  
                                            USER_LAST_NAME_PROPERTY_DEFAULT),
 249  
                                        userObject);
 250  
 
 251  16
             emailPropDesc =
 252  
                 new PropertyDescriptor(conf.getString(
 253  
                                            USER_EMAIL_PROPERTY_KEY,
 254  
                                            USER_EMAIL_PROPERTY_DEFAULT),
 255  
                                        userObject);
 256  
 
 257  16
             confirmPropDesc =
 258  
                 new PropertyDescriptor(conf.getString(
 259  
                                            USER_CONFIRM_PROPERTY_KEY,
 260  
                                            USER_CONFIRM_PROPERTY_DEFAULT),
 261  
                                        userObject);
 262  
 
 263  16
             createDatePropDesc =
 264  
                 new PropertyDescriptor(conf.getString(
 265  
                                            USER_CREATE_PROPERTY_KEY,
 266  
                                            USER_CREATE_PROPERTY_DEFAULT),
 267  
                                        userObject);
 268  
 
 269  16
             lastLoginPropDesc  =
 270  
                 new PropertyDescriptor(conf.getString(
 271  
                                            USER_LAST_LOGIN_PROPERTY_KEY,
 272  
                                            USER_LAST_LOGIN_PROPERTY_DEFAULT),
 273  
                                        userObject);
 274  
 
 275  16
             objectdataPropDesc =
 276  
                 new PropertyDescriptor(conf.getString(
 277  
                                            USER_OBJECTDATA_PROPERTY_KEY,
 278  
                                            USER_OBJECTDATA_PROPERTY_DEFAULT),
 279  
                                        userObject);
 280  8
         }
 281  0
         catch (Exception e)
 282  
         {
 283  0
             if (userPeerClassName == null || userPeerClass == class="keyword">null)
 284  
             {
 285  0
                 throw new InitializationException(
 286  
                     "Could not find UserPeer class ("
 287  
                     + userPeerClassName + ")", e);
 288  
             }
 289  0
             if (tableName == null)
 290  
             {
 291  0
                 throw new InitializationException(
 292  
                     "Failed to get the table name from the Peer object", e);
 293  
             }
 294  
 
 295  0
             if (userObject == null || userObjectName == class="keyword">null)
 296  
             {
 297  0
                 throw new InitializationException(
 298  
                     "Failed to get the object type from the Peer object", e);
 299  
             }
 300  
 
 301  
 
 302  0
             if (nameColumn == null || namePropDesc == class="keyword">null)
 303  
             {
 304  0
                 throw new InitializationException(
 305  
                     "UserPeer " + userPeerClassName
 306  
                     + " has no name column information!", e);
 307  
             }
 308  0
             if (idColumn == null || idPropDesc == class="keyword">null)
 309  
             {
 310  0
                 throw new InitializationException(
 311  
                     "UserPeer " + userPeerClassName
 312  
                     + " has no id column information!", e);
 313  
             }
 314  0
             if (passwordColumn == null || passwordPropDesc == class="keyword">null)
 315  
             {
 316  0
                 throw new InitializationException(
 317  
                     "UserPeer " + userPeerClassName
 318  
                     + " has no password column information!", e);
 319  
             }
 320  0
             if (firstNameColumn == null || firstNamePropDesc == class="keyword">null)
 321  
             {
 322  0
                 throw new InitializationException(
 323  
                     "UserPeer " + userPeerClassName
 324  
                     + " has no firstName column information!", e);
 325  
             }
 326  0
             if (lastNameColumn == null || lastNamePropDesc == class="keyword">null)
 327  
             {
 328  0
                 throw new InitializationException(
 329  
                     "UserPeer " + userPeerClassName
 330  
                     + " has no lastName column information!", e);
 331  
             }
 332  0
             if (emailColumn == null || emailPropDesc == class="keyword">null)
 333  
             {
 334  0
                 throw new InitializationException(
 335  
                     "UserPeer " + userPeerClassName
 336  
                     + " has no email column information!", e);
 337  
             }
 338  0
             if (confirmColumn == null || confirmPropDesc == class="keyword">null)
 339  
             {
 340  0
                 throw new InitializationException(
 341  
                     "UserPeer " + userPeerClassName
 342  
                     + " has no confirm column information!", e);
 343  
             }
 344  0
             if (createDateColumn == null || createDatePropDesc == class="keyword">null)
 345  
             {
 346  0
                 throw new InitializationException(
 347  
                     "UserPeer " + userPeerClassName
 348  
                     + " has no createDate column information!", e);
 349  
             }
 350  0
             if (lastLoginColumn == null || lastLoginPropDesc == class="keyword">null)
 351  
             {
 352  0
                 throw new InitializationException(
 353  
                     "UserPeer " + userPeerClassName
 354  
                     + " has no lastLogin column information!", e);
 355  
             }
 356  0
             if (objectdataColumn == null || objectdataPropDesc == class="keyword">null)
 357  
             {
 358  0
                 throw new InitializationException(
 359  
                     "UserPeer " + userPeerClassName
 360  
                     + " has no objectdata column information!", e);
 361  
             }
 362  8
         }
 363  16
     }
 364  
 
 365  
     /**
 366  
      * Get the name of this table.
 367  
      *
 368  
      * @return A String with the name of the table.
 369  
      */
 370  
     public static String getTableName()
 371  
     {
 372  0
         return tableName;
 373  
     }
 374  
 
 375  
     /**
 376  
      * Returns the fully qualified name of the Column to
 377  
      * use as the Name Column for a group
 378  
      *
 379  
      * @return A String containing the column name
 380  
      */
 381  
     public static String getNameColumn()
 382  
     {
 383  234
         return nameColumn;
 384  
     }
 385  
 
 386  
     /**
 387  
      * Returns the fully qualified name of the Column to
 388  
      * use as the Id Column for a group
 389  
      *
 390  
      * @return A String containing the column id
 391  
      */
 392  
     public static String getIdColumn()
 393  
     {
 394  42
         return idColumn;
 395  
     }
 396  
 
 397  
     /**
 398  
      * Returns the fully qualified name of the Column to
 399  
      * use as the Password Column for a role
 400  
      *
 401  
      * @return A String containing the column name
 402  
      */
 403  
     public static String getPasswordColumn()
 404  
     {
 405  0
         return passwordColumn;
 406  
     }
 407  
 
 408  
     /**
 409  
      * Returns the fully qualified name of the Column to
 410  
      * use as the FirstName Column for a role
 411  
      *
 412  
      * @return A String containing the column name
 413  
      */
 414  
     public static String getFirstNameColumn()
 415  
     {
 416  0
         return firstNameColumn;
 417  
     }
 418  
 
 419  
     /**
 420  
      * Returns the fully qualified name of the Column to
 421  
      * use as the LastName Column for a role
 422  
      *
 423  
      * @return A String containing the column name
 424  
      */
 425  
     public static String getLastNameColumn()
 426  
     {
 427  0
         return lastNameColumn;
 428  
     }
 429  
 
 430  
     /**
 431  
      * Returns the fully qualified name of the Column to
 432  
      * use as the Email Column for a role
 433  
      *
 434  
      * @return A String containing the column name
 435  
      */
 436  
     public static String getEmailColumn()
 437  
     {
 438  0
         return emailColumn;
 439  
     }
 440  
 
 441  
     /**
 442  
      * Returns the fully qualified name of the Column to
 443  
      * use as the Confirm Column for a role
 444  
      *
 445  
      * @return A String containing the column name
 446  
      */
 447  
     public static String getConfirmColumn()
 448  
     {
 449  0
         return confirmColumn;
 450  
     }
 451  
 
 452  
     /**
 453  
      * Returns the fully qualified name of the Column to
 454  
      * use as the CreateDate Column for a role
 455  
      *
 456  
      * @return A String containing the column name
 457  
      */
 458  
     public static String getCreateDateColumn()
 459  
     {
 460  0
         return createDateColumn;
 461  
     }
 462  
 
 463  
     /**
 464  
      * Returns the fully qualified name of the Column to
 465  
      * use as the LastLogin Column for a role
 466  
      *
 467  
      * @return A String containing the column name
 468  
      */
 469  
     public static String getLastLoginColumn()
 470  
     {
 471  0
         return lastLoginColumn;
 472  
     }
 473  
 
 474  
     /**
 475  
      * Returns the fully qualified name of the Column to
 476  
      * use as the objectdata Column for a role
 477  
      *
 478  
      * @return A String containing the column name
 479  
      */
 480  
     public static String getObjectdataColumn()
 481  
     {
 482  0
         return objectdataColumn;
 483  
     }
 484  
 
 485  
     /**
 486  
      * Returns the full name of a column.
 487  
      *
 488  
      * @param name The column to fully qualify
 489  
      *
 490  
      * @return A String with the full name of the column.
 491  
      */
 492  
     public static String getColumnName(String name)
 493  
     {
 494  0
         StringBuffer sb = new StringBuffer();
 495  0
         sb.append(getTableName());
 496  0
         sb.append(".");
 497  0
         sb.append(name);
 498  0
         return sb.toString();
 499  
     }
 500  
 
 501  
     /**
 502  
      * Returns the full name of a column.
 503  
      *
 504  
      * @param name The column to fully qualify
 505  
      *
 506  
      * @return A String with the full name of the column.
 507  
      * @deprecated use getColumnName(String name)
 508  
      */
 509  
     public String getFullColumnName(String name)
 510  
     {
 511  0
         return getColumnName(name);
 512  
     }
 513  
 
 514  
 
 515  
     /**
 516  
      * Returns a new, empty object for the underlying peer.
 517  
      * Used to create a new underlying object
 518  
      *
 519  
      * @return A new object which is compatible to the Peer
 520  
      *         and can be used as a User object
 521  
      *
 522  
      */
 523  
 
 524  
     public static Persistent newPersistentInstance()
 525  
     {
 526  24
         Persistent obj = null;
 527  
 
 528  24
         if (userObject == null)
 529  
         {
 530  
             // This can happen if the Turbine wants to determine the
 531  
             // name of the anonymous user before the security service
 532  
             // has been initialized. In this case, the Peer Manager
 533  
             // has not yet been inited and the userObject is still
 534  
             // null. Return null in this case.
 535  
             //
 536  0
             return obj;
 537  
         }
 538  
 
 539  
         try
 540  
         {
 541  24
             obj = (Persistent) userObject.newInstance();
 542  12
         }
 543  0
         catch (Exception e)
 544  
         {
 545  0
             log.error("Could not instantiate a user object", e);
 546  0
             obj = null;
 547  12
         }
 548  24
         return obj;
 549  
     }
 550  
 
 551  
     /**
 552  
      * Checks if a User is defined in the system. The name
 553  
      * is used as query criteria.
 554  
      *
 555  
      * @param user The User to be checked.
 556  
      * @return <code>true</code> if given User exists in the system.
 557  
      * @throws DataBackendException when more than one User with
 558  
      *         the same name exists.
 559  
      * @throws Exception A generic exception.
 560  
      */
 561  
     public static boolean checkExists(User user)
 562  
         throws DataBackendException, Exception
 563  
     {
 564  0
         Criteria criteria = new Criteria();
 565  
 
 566  0
         criteria.addSelectColumn(getIdColumn());
 567  
 
 568  0
         criteria.add(getNameColumn(), user.getName());
 569  
 
 570  0
         List results = BasePeer.doSelect(criteria);
 571  
 
 572  0
         if (results.size() > 1)
 573  
         {
 574  0
             throw new DataBackendException("Multiple users named '" +
 575  
                                            user.getName() + "' exist!");
 576  
         }
 577  0
         return (results.size() == 1);
 578  
     }
 579  
 
 580  
     /**
 581  
      * Returns a List of all User objects.
 582  
      *
 583  
      * @return A List with all users in the system.
 584  
      * @exception Exception A generic exception.
 585  
      */
 586  
     public static List selectAllUsers()
 587  
         throws Exception
 588  
     {
 589  0
         Criteria criteria = new Criteria();
 590  0
         criteria.addAscendingOrderByColumn(getLastNameColumn());
 591  0
         criteria.addAscendingOrderByColumn(getFirstNameColumn());
 592  0
         criteria.setIgnoreCase(true);
 593  0
         return doSelect(criteria);
 594  
     }
 595  
 
 596  
     /**
 597  
      * Returns a List of all confirmed User objects.
 598  
      *
 599  
      * @return A List with all confirmed users in the system.
 600  
      * @exception Exception A generic exception.
 601  
      */
 602  
     public static List selectAllConfirmedUsers()
 603  
         throws Exception
 604  
     {
 605  0
         Criteria criteria = new Criteria();
 606  
 
 607  0
         criteria.add (getConfirmColumn(), User.CONFIRM_DATA);
 608  0
         criteria.addAscendingOrderByColumn(getLastNameColumn());
 609  0
         criteria.addAscendingOrderByColumn(getFirstNameColumn());
 610  0
         criteria.setIgnoreCase(true);
 611  0
         return doSelect(criteria);
 612  
     }
 613  
 
 614  
     /*
 615  
      * ========================================================================
 616  
      *
 617  
      * WARNING! Do not read on if you have a weak stomach. What follows here
 618  
      * are some abominations thanks to the braindead static peers of Torque
 619  
      * and the rigidity of Java....
 620  
      *
 621  
      * ========================================================================
 622  
      *
 623  
      */
 624  
 
 625  
     /**
 626  
      * Calls buildCriteria(User user) in the configured UserPeer. If you get
 627  
      * a ClassCastException in this routine, you put a User object into this
 628  
      * method which can't be cast into an object for the TorqueSecurityService. This is a
 629  
      * configuration error most of the time.
 630  
      *
 631  
      * @param user An object which implements the User interface
 632  
      *
 633  
      * @return A criteria for the supplied user object
 634  
      */
 635  
 
 636  
     public static Criteria buildCriteria(User user)
 637  
     {
 638  
         Criteria crit;
 639  
 
 640  
         try
 641  
         {
 642  0
             Class[] clazz = new Class[] { userObject };
 643  0
             Object[] params =
 644  
                 new Object[] { ((TorqueUser) user).getPersistentObj() };
 645  
 
 646  0
             crit =  (Criteria) userPeerClass
 647  
                 .getMethod("buildCriteria", clazz)
 648  
                 .invoke(null, params);
 649  
         }
 650  0
         catch (Exception e)
 651  
         {
 652  0
             crit = null;
 653  0
         }
 654  
 
 655  0
         return crit;
 656  
     }
 657  
 
 658  
     /**
 659  
      * Invokes doUpdate(Criteria c) on the configured Peer Object
 660  
      *
 661  
      * @param criteria  A Criteria Object
 662  
      *
 663  
      * @exception TorqueException A problem occured.
 664  
      */
 665  
 
 666  
     public static void doUpdate(Criteria criteria)
 667  
         throws TorqueException
 668  
     {
 669  
         try
 670  
         {
 671  0
             Class[] clazz = new Class[] { Criteria.class };
 672  0
             Object[] params = new Object[] { criteria };
 673  
 
 674  0
             userPeerClass
 675  
                 .getMethod("doUpdate", clazz)
 676  
                 .invoke(null, params);
 677  
         }
 678  0
         catch (Exception e)
 679  
         {
 680  0
             throw new TorqueException("doUpdate failed", e);
 681  0
         }
 682  0
     }
 683  
 
 684  
     /**
 685  
      * Invokes doInsert(Criteria c) on the configured Peer Object
 686  
      *
 687  
      * @param criteria  A Criteria Object
 688  
      *
 689  
      * @exception TorqueException A problem occured.
 690  
      */
 691  
 
 692  
     public static void doInsert(Criteria criteria)
 693  
         throws TorqueException
 694  
     {
 695  
         try
 696  
         {
 697  0
             Class[] clazz = new Class[] { Criteria.class };
 698  0
             Object[] params = new Object[] { criteria };
 699  
 
 700  0
             userPeerClass
 701  
                 .getMethod("doInsert", clazz)
 702  
                 .invoke(null, params);
 703  
         }
 704  0
         catch (Exception e)
 705  
         {
 706  0
             throw new TorqueException("doInsert failed", e);
 707  0
         }
 708  0
     }
 709  
 
 710  
     /**
 711  
      * Invokes doSelect(Criteria c) on the configured Peer Object
 712  
      *
 713  
      * @param criteria  A Criteria Object
 714  
      *
 715  
      * @return A List of User Objects selected by the Criteria
 716  
      *
 717  
      * @exception TorqueException A problem occured.
 718  
      */
 719  
     public static List doSelect(Criteria criteria)
 720  
         throws TorqueException
 721  
     {
 722  
         List list;
 723  
 
 724  
         try
 725  
         {
 726  254
             Class[] clazz =
 727  
                 new Class[] { Criteria.class };
 728  254
             Object[] params = new Object[] { criteria };
 729  
 
 730  254
             list = (List) userPeerClass
 731  
                 .getMethod("doSelect", clazz)
 732  
                 .invoke(null, params);
 733  127
         }
 734  0
         catch (Exception e)
 735  
         {
 736  0
             throw new TorqueException("doSelect failed", e);
 737  127
         }
 738  254
         List newList = new ArrayList(list.size());
 739  
 
 740  
         //
 741  
         // Wrap the returned Objects into TorqueUsers.
 742  
         //
 743  524
         for (Iterator it = list.iterator(); it.hasNext(); )
 744  
         {
 745  286
             User u = getNewUser((Persistent) it.next());
 746  286
             newList.add(u);
 747  
         }
 748  
 
 749  254
         return newList;
 750  
     }
 751  
 
 752  
     /**
 753  
      * Invokes doDelete(Criteria c) on the configured Peer Object
 754  
      *
 755  
      * @param criteria  A Criteria Object
 756  
      *
 757  
      * @exception TorqueException A problem occured.
 758  
      */
 759  
     public static void doDelete(Criteria criteria)
 760  
         throws TorqueException
 761  
     {
 762  
         try
 763  
         {
 764  4
             Class[] clazz = new Class[] { Criteria.class };
 765  4
             Object[] params = new Object[] { criteria };
 766  
 
 767  4
             userPeerClass
 768  
                 .getMethod("doDelete", clazz)
 769  
                 .invoke(null, params);
 770  2
         }
 771  0
         catch (Exception e)
 772  
         {
 773  0
             throw new TorqueException("doDelete failed", e);
 774  2
         }
 775  4
     }
 776  
 
 777  
     /**
 778  
      * Invokes setName(String s) on the supplied base object
 779  
      *
 780  
      * @param obj The object to use for setting the name
 781  
      * @param name The Name to set
 782  
      */
 783  
     public static void setUserName(Persistent obj, String name)
 784  
     {
 785  16
         if (obj == null)
 786  
         {
 787  0
             return;
 788  
         }
 789  
 
 790  
         try
 791  
         {
 792  16
             Object[] params = new Object[] { name };
 793  16
             namePropDesc.getWriteMethod().invoke(obj, params);
 794  8
         }
 795  0
         catch (ClassCastException cce)
 796  
         {
 797  0
             String msg = obj.getClass().getName() + " does not seem to be an User Object!";
 798  0
             log.error(msg);
 799  0
             throw new RuntimeException(msg);
 800  
         }
 801  0
         catch (Exception e)
 802  
         {
 803  0
             log.error(e, e);
 804  8
         }
 805  16
     }
 806  
 
 807  
     /**
 808  
      * Invokes getName() on the supplied base object
 809  
      *
 810  
      * @param obj The object to use for getting the name
 811  
      *
 812  
      * @return A string containing the name
 813  
      *
 814  
      * @deprecated use getName(obj)
 815  
      */
 816  
     public static String getUserName(Persistent obj)
 817  
     {
 818  0
         return getName(obj);
 819  
     }
 820  
 
 821  
     /**
 822  
      * Invokes getName() on the supplied base object
 823  
      *
 824  
      * @param obj The object to use for getting the name
 825  
      *
 826  
      * @return A string containing the name
 827  
      */
 828  
     public static String getName(Persistent obj)
 829  
     {
 830  182
         String name = null;
 831  
 
 832  182
         if (obj == null)
 833  
         {
 834  0
             return null;
 835  
         }
 836  
 
 837  
         try
 838  
         {
 839  182
             name = (String) namePropDesc
 840  
                 .getReadMethod()
 841  
                 .invoke(obj, new Object[] {});
 842  91
         }
 843  0
         catch (ClassCastException cce)
 844  
         {
 845  0
             String msg = obj.getClass().getName() + " does not seem to be an User Object!";
 846  0
             log.error(msg);
 847  0
             throw new RuntimeException(msg);
 848  
         }
 849  0
         catch (Exception e)
 850  
         {
 851  0
             log.error(e, e);
 852  91
         }
 853  182
         return name;
 854  
     }
 855  
 
 856  
     /**
 857  
      * Invokes setPassword(String s) on the supplied base object
 858  
      *
 859  
      * @param obj The object to use for setting the password
 860  
      * @param password The Password to set
 861  
      */
 862  
     public static void setUserPassword(Persistent obj, String password)
 863  
     {
 864  16
         if (obj == null)
 865  
         {
 866  0
             return;
 867  
         }
 868  
 
 869  
         try
 870  
         {
 871  16
             Object[] params = new Object[] { password };
 872  16
             passwordPropDesc.getWriteMethod().invoke(obj, params);
 873  8
         }
 874  0
         catch (ClassCastException cce)
 875  
         {
 876  0
             String msg = obj.getClass().getName() + " does not seem to be an User Object!";
 877  0
             log.error(msg);
 878  0
             throw new RuntimeException(msg);
 879  
         }
 880  0
         catch (Exception e)
 881  
         {
 882  0
             log.error(e, e);
 883  8
         }
 884  16
     }
 885  
 
 886  
     /**
 887  
      * Invokes getPassword() on the supplied base object
 888  
      *
 889  
      * @param obj The object to use for getting the password
 890  
      *
 891  
      * @return A string containing the password
 892  
      */
 893  
     public static String getUserPassword(Persistent obj)
 894  
     {
 895  38
         String password = null;
 896  
 
 897  38
         if (obj == null)
 898  
         {
 899  0
             return null;
 900  
         }
 901  
 
 902  
         try
 903  
         {
 904  38
             password = (String) passwordPropDesc
 905  
                 .getReadMethod()
 906  
                 .invoke(obj, new Object[] {});
 907  19
         }
 908  0
         catch (ClassCastException cce)
 909  
         {
 910  0
             String msg = obj.getClass().getName() + " does not seem to be an User Object!";
 911  0
             log.error(msg);
 912  0
             throw new RuntimeException(msg);
 913  
         }
 914  0
         catch (Exception e)
 915  
         {
 916  0
             log.error(e, e);
 917  19
         }
 918  38
         return password;
 919  
     }
 920  
 
 921  
     /**
 922  
      * Invokes setFirstName(String s) on the supplied base object
 923  
      *
 924  
      * @param obj The object to use for setting the first name
 925  
      * @param firstName The first name to set
 926  
      */
 927  
     public static void setUserFirstName(Persistent obj, String firstName)
 928  
     {
 929  4
         if (obj == null)
 930  
         {
 931  0
             return;
 932  
         }
 933  
 
 934  
         try
 935  
         {
 936  4
             Object[] params = new Object[] { firstName };
 937  4
             firstNamePropDesc.getWriteMethod().invoke(obj, params);
 938  2
         }
 939  0
         catch (ClassCastException cce)
 940  
         {
 941  0
             String msg = obj.getClass().getName() + " does not seem to be an User Object!";
 942  0
             log.error(msg);
 943  0
             throw new RuntimeException(msg);
 944  
         }
 945  0
         catch (Exception e)
 946  
         {
 947  0
             log.error(e, e);
 948  2
         }
 949  4
     }
 950  
 
 951  
     /**
 952  
      * Invokes getFirstName() on the supplied base object
 953  
      *
 954  
      * @param obj The object to use for getting the first name
 955  
      *
 956  
      * @return A string containing the first name
 957  
      */
 958  
     public static String getUserFirstName(Persistent obj)
 959  
     {
 960  0
         String firstName = null;
 961  
 
 962  0
         if (obj == null)
 963  
         {
 964  0
             return null;
 965  
         }
 966  
 
 967  
         try
 968  
         {
 969  0
             firstName = (String) firstNamePropDesc
 970  
                 .getReadMethod()
 971  
                 .invoke(obj, new Object[] {});
 972  
         }
 973  0
         catch (ClassCastException cce)
 974  
         {
 975  0
             String msg = obj.getClass().getName() + " does not seem to be an User Object!";
 976  0
             log.error(msg);
 977  0
             throw new RuntimeException(msg);
 978  
         }
 979  0
         catch (Exception e)
 980  
         {
 981  0
             log.error(e, e);
 982  0
         }
 983  0
         return firstName;
 984  
     }
 985  
 
 986  
     /**
 987  
      * Invokes setLastName(String s) on the supplied base object
 988  
      *
 989  
      * @param obj The object to use for setting the last name
 990  
      * @param lastName The Last Name to set
 991  
      */
 992  
     public static void setUserLastName(Persistent obj, String lastName)
 993  
     {
 994  4
         if (obj == null)
 995  
         {
 996  0
             return;
 997  
         }
 998  
 
 999  
         try
 1000  
         {
 1001  4
             Object[] params = new Object[] { lastName };
 1002  4
             lastNamePropDesc.getWriteMethod().invoke(obj, params);
 1003  2
         }
 1004  0
         catch (ClassCastException cce)
 1005  
         {
 1006  0
             String msg = obj.getClass().getName() + " does not seem to be an User Object!";
 1007  0
             log.error(msg);
 1008  0
             throw new RuntimeException(msg);
 1009  
         }
 1010  0
         catch (Exception e)
 1011  
         {
 1012  0
             log.error(e, e);
 1013  2
         }
 1014  4
     }
 1015  
 
 1016  
     /**
 1017  
      * Invokes getLastName() on the supplied base object
 1018  
      *
 1019  
      * @param obj The object to use for getting the last name
 1020  
      *
 1021  
      * @return A string containing the last name
 1022  
      */
 1023  
     public static String getUserLastName(Persistent obj)
 1024  
     {
 1025  0
         String lastName = null;
 1026  
 
 1027  0
         if (obj == null)
 1028  
         {
 1029  0
             return null;
 1030  
         }
 1031  
 
 1032  
         try
 1033  
         {
 1034  0
             lastName = (String) lastNamePropDesc
 1035  
                 .getReadMethod()
 1036  
                 .invoke(obj, new Object[] {});
 1037  
         }
 1038  0
         catch (ClassCastException cce)
 1039  
         {
 1040  0
             String msg = obj.getClass().getName() + " does not seem to be an User Object!";
 1041  0
             log.error(msg);
 1042  0
             throw new RuntimeException(msg);
 1043  
         }
 1044  0
         catch (Exception e)
 1045  
         {
 1046  0
             log.error(e, e);
 1047  0
         }
 1048  0
         return lastName;
 1049  
     }
 1050  
 
 1051  
     /**
 1052  
      * Invokes setEmail(String s) on the supplied base object
 1053  
      *
 1054  
      * @param obj The object to use for setting the email
 1055  
      * @param email The Email to set
 1056  
      */
 1057  
     public static void setUserEmail(Persistent obj, String email)
 1058  
     {
 1059  0
         if (obj == null)
 1060  
         {
 1061  0
             return;
 1062  
         }
 1063  
 
 1064  
         try
 1065  
         {
 1066  0
             Object[] params = new Object[] { email };
 1067  0
             emailPropDesc.getWriteMethod().invoke(obj, params);
 1068  
         }
 1069  0
         catch (ClassCastException cce)
 1070  
         {
 1071  0
             String msg = obj.getClass().getName() + " does not seem to be an User Object!";
 1072  0
             log.error(msg);
 1073  0
             throw new RuntimeException(msg);
 1074  
         }
 1075  0
         catch (Exception e)
 1076  
         {
 1077  0
             log.error(e, e);
 1078  0
         }
 1079  0
     }
 1080  
 
 1081  
     /**
 1082  
      * Invokes getEmail() on the supplied base object
 1083  
      *
 1084  
      * @param obj The object to use for getting the email
 1085  
      *
 1086  
      * @return A string containing the email
 1087  
      */
 1088  
     public static String getUserEmail(Persistent obj)
 1089  
     {
 1090  0
         String email = null;
 1091  
 
 1092  0
         if (obj == null)
 1093  
         {
 1094  0
             return null;
 1095  
         }
 1096  
 
 1097  
         try
 1098  
         {
 1099  0
             email = (String) emailPropDesc
 1100  
                 .getReadMethod()
 1101  
                 .invoke(obj, new Object[] {});
 1102  
         }
 1103  0
         catch (ClassCastException cce)
 1104  
         {
 1105  0
             String msg = obj.getClass().getName() + " does not seem to be an User Object!";
 1106  0
             log.error(msg);
 1107  0
             throw new RuntimeException(msg);
 1108  
         }
 1109  0
         catch (Exception e)
 1110  
         {
 1111  0
             log.error(e, e);
 1112  0
         }
 1113  0
         return email;
 1114  
     }
 1115  
 
 1116  
     /**
 1117  
      * Invokes setConfirmed(String s) on the supplied base object
 1118  
      *
 1119  
      * @param obj The object to use for setting the confirm value
 1120  
      * @param confirm The confirm value to set
 1121  
      */
 1122  
     public static void setUserConfirmed(Persistent obj, String confirm)
 1123  
     {
 1124  0
         if (obj == null)
 1125  
         {
 1126  0
             return;
 1127  
         }
 1128  
 
 1129  
         try
 1130  
         {
 1131  0
             Object[] params = new Object[] { confirm };
 1132  0
             confirmPropDesc.getWriteMethod().invoke(obj, params);
 1133  
         }
 1134  0
         catch (ClassCastException cce)
 1135  
         {
 1136  0
             String msg = obj.getClass().getName() + " does not seem to be an User Object!";
 1137  0
             log.error(msg);
 1138  0
             throw new RuntimeException(msg);
 1139  
         }
 1140  0
         catch (Exception e)
 1141  
         {
 1142  0
             log.error(e, e);
 1143  0
         }
 1144  0
     }
 1145  
 
 1146  
     /**
 1147  
      * Invokes getConfirmed() on the supplied base object
 1148  
      *
 1149  
      * @param obj The object to use for getting the confirm value
 1150  
      *
 1151  
      * @return A string containing the confirm value
 1152  
      */
 1153  
     public static String getUserConfirmed(Persistent obj)
 1154  
     {
 1155  0
         String confirm = null;
 1156  
 
 1157  0
         if (obj == null)
 1158  
         {
 1159  0
             return null;
 1160  
         }
 1161  
 
 1162  
         try
 1163  
         {
 1164  0
             confirm = (String) confirmPropDesc
 1165  
                 .getReadMethod()
 1166  
                 .invoke(obj, new Object[] {});
 1167  
         }
 1168  0
         catch (ClassCastException cce)
 1169  
         {
 1170  0
             String msg = obj.getClass().getName() + " does not seem to be an User Object!";
 1171  0
             log.error(msg);
 1172  0
             throw new RuntimeException(msg);
 1173  
         }
 1174  0
         catch (Exception e)
 1175  
         {
 1176  0
             log.error(e, e);
 1177  0
         }
 1178  0
         return confirm;
 1179  
     }
 1180  
 
 1181  
     /**
 1182  
      * Invokes setCreateDate(java.util.Date date) on the supplied base object
 1183  
      *
 1184  
      * @param obj The object to use for setting the create date
 1185  
      * @param createDate The create date to set
 1186  
      */
 1187  
     public static void setUserCreateDate(Persistent obj, java.util.Date createDate)
 1188  
     {
 1189  24
         if (obj == null)
 1190  
         {
 1191  0
             return;
 1192  
         }
 1193  
 
 1194  
         try
 1195  
         {
 1196  24
             Object[] params = new Object[] { createDate };
 1197  24
             createDatePropDesc.getWriteMethod().invoke(obj, params);
 1198  12
         }
 1199  0
         catch (ClassCastException cce)
 1200  
         {
 1201  0
             String msg = obj.getClass().getName() + " does not seem to be an User Object!";
 1202  0
             log.error(msg);
 1203  0
             throw new RuntimeException(msg);
 1204  
         }
 1205  0
         catch (Exception e)
 1206  
         {
 1207  0
             log.error(e, e);
 1208  12
         }
 1209  24
     }
 1210  
 
 1211  
     /**
 1212  
      * Invokes getCreateDate() on the supplied base object
 1213  
      *
 1214  
      * @param obj The object to use for getting the create date
 1215  
      *
 1216  
      * @return A string containing the create date
 1217  
      */
 1218  
     public static java.util.Date getUserCreateDate(Persistent obj)
 1219  
     {
 1220  0
         java.util.Date createDate = null;
 1221  
 
 1222  0
         if (obj == null)
 1223  
         {
 1224  0
             return null;
 1225  
         }
 1226  
 
 1227  
         try
 1228  
         {
 1229  0
             createDate = (java.util.Date) createDatePropDesc
 1230  
                 .getReadMethod()
 1231  
                 .invoke(obj, new Object[] {});
 1232  
         }
 1233  0
         catch (ClassCastException cce)
 1234  
         {
 1235  0
             String msg = obj.getClass().getName() + " does not seem to be an User Object!";
 1236  0
             log.error(msg);
 1237  0
             throw new RuntimeException(msg);
 1238  
         }
 1239  0
         catch (Exception e)
 1240  
         {
 1241  0
             log.error(e, e);
 1242  0
         }
 1243  0
         return createDate;
 1244  
     }
 1245  
 
 1246  
     /**
 1247  
      * Invokes setLastLogin(java.util.Date date) on the supplied base object
 1248  
      *
 1249  
      * @param obj The object to use for setting the last login daet
 1250  
      * @param lastLogin The last login date to set
 1251  
      */
 1252  
     public static void setUserLastLogin(Persistent obj, java.util.Date lastLogin)
 1253  
     {
 1254  0
         if (obj == null)
 1255  
         {
 1256  0
             return;
 1257  
         }
 1258  
 
 1259  
         try
 1260  
         {
 1261  0
             Object[] params = new Object[] { lastLogin };
 1262  0
             lastLoginPropDesc.getWriteMethod().invoke(obj, params);
 1263  
         }
 1264  0
         catch (ClassCastException cce)
 1265  
         {
 1266  0
             String msg = obj.getClass().getName() + " does not seem to be an User Object!";
 1267  0
             log.error(msg);
 1268  0
             throw new RuntimeException(msg);
 1269  
         }
 1270  0
         catch (Exception e)
 1271  
         {
 1272  0
             log.error(e, e);
 1273  0
         }
 1274  0
     }
 1275  
 
 1276  
     /**
 1277  
      * Invokes getLastLogin() on the supplied base object
 1278  
      *
 1279  
      * @param obj The object to use for getting the last login date
 1280  
      *
 1281  
      * @return A string containing the last login date
 1282  
      */
 1283  
     public static java.util.Date getUserLastLogin(Persistent obj)
 1284  
     {
 1285  0
         java.util.Date lastLogin = null;
 1286  
 
 1287  0
         if (obj == null)
 1288  
         {
 1289  0
             return null;
 1290  
         }
 1291  
 
 1292  
         try
 1293  
         {
 1294  0
             lastLogin = (java.util.Date) lastLoginPropDesc
 1295  
                 .getReadMethod()
 1296  
                 .invoke(obj, new Object[] {});
 1297  
         }
 1298  0
         catch (ClassCastException cce)
 1299  
         {
 1300  0
             String msg = obj.getClass().getName() + " does not seem to be an User Object!";
 1301  0
             log.error(msg);
 1302  0
             throw new RuntimeException(msg);
 1303  
         }
 1304  0
         catch (Exception e)
 1305  
         {
 1306  0
             log.error(e, e);
 1307  0
         }
 1308  0
         return lastLogin;
 1309  
     }
 1310  
 
 1311  
     /**
 1312  
      * Invokes setObjectdata(byte [] date) on the supplied base object
 1313  
      *
 1314  
      * @param obj The object to use for setting the last login daet
 1315  
      * @param objectdata The objectdata to use
 1316  
      */
 1317  
     public static void setUserObjectdata(Persistent obj, byte [] objectdata)
 1318  
     {
 1319  22
         if (obj == null)
 1320  
         {
 1321  0
             return;
 1322  
         }
 1323  
 
 1324  
         try
 1325  
         {
 1326  22
             Object[] params = new Object[] { objectdata };
 1327  22
             objectdataPropDesc.getWriteMethod().invoke(obj, params);
 1328  11
         }
 1329  0
         catch (ClassCastException cce)
 1330  
         {
 1331  0
             String msg = obj.getClass().getName() + " does not seem to be an User Object!";
 1332  0
             log.error(msg);
 1333  0
             throw new RuntimeException(msg);
 1334  
         }
 1335  0
         catch (Exception e)
 1336  
         {
 1337  0
             log.error(e, e);
 1338  11
         }
 1339  22
     }
 1340  
 
 1341  
     /**
 1342  
      * Invokes getObjectdata() on the supplied base object
 1343  
      *
 1344  
      * @param obj The object to use for getting the last login date
 1345  
      *
 1346  
      * @return A string containing the last login date
 1347  
      */
 1348  
     public static byte [] getUserObjectdata(Persistent obj)
 1349  
     {
 1350  20
         byte [] objectdata = null;
 1351  
 
 1352  20
         if (obj == null)
 1353  
         {
 1354  0
             return null;
 1355  
         }
 1356  
 
 1357  
         try
 1358  
         {
 1359  20
             objectdata = (byte []) objectdataPropDesc
 1360  
                 .getReadMethod()
 1361  
                 .invoke(obj, new Object[] {});
 1362  10
         }
 1363  0
         catch (ClassCastException cce)
 1364  
         {
 1365  0
             String msg = obj.getClass().getName() + " does not seem to be an User Object!";
 1366  0
             log.error(msg);
 1367  0
             throw new RuntimeException(msg);
 1368  
         }
 1369  0
         catch (Exception e)
 1370  
         {
 1371  0
             log.error(e, e);
 1372  10
         }
 1373  20
         return objectdata;
 1374  
     }
 1375  
 
 1376  
     /**
 1377  
      * Invokes setId(int n) on the supplied base object
 1378  
      *
 1379  
      * @param obj The object to use for setting the name
 1380  
      * @param id The new Id
 1381  
      */
 1382  
     public static void setId(Persistent obj, int id)
 1383  
     {
 1384  0
         if (obj == null)
 1385  
         {
 1386  0
             return;
 1387  
         }
 1388  
 
 1389  
         try
 1390  
         {
 1391  0
             Object[] params = new Object[] { Integer.TYPE };
 1392  0
             idPropDesc.getWriteMethod().invoke(obj, params);
 1393  
         }
 1394  0
         catch (ClassCastException cce)
 1395  
         {
 1396  0
             String msg = obj.getClass().getName() + " does not seem to be an User Object!";
 1397  0
             log.error(msg);
 1398  0
             throw new RuntimeException(msg);
 1399  
         }
 1400  0
         catch (Exception e)
 1401  
         {
 1402  0
             log.error(e, e);
 1403  0
         }
 1404  0
     }
 1405  
 
 1406  
     /**
 1407  
      * Invokes getId() on the supplied base object
 1408  
      *
 1409  
      * @param obj The object to use for getting the id
 1410  
      *
 1411  
      * @return The Id of this object
 1412  
      */
 1413  
     public static Integer getIdAsObj(Persistent obj)
 1414  
     {
 1415  4
         Integer id = null;
 1416  
 
 1417  4
         if (obj == null)
 1418  
         {
 1419  0
             return new Integer(0);
 1420  
         }
 1421  
 
 1422  
         try
 1423  
         {
 1424  4
             id = (Integer) idPropDesc
 1425  
                 .getReadMethod()
 1426  
                 .invoke(obj, new Object[] {});
 1427  2
         }
 1428  0
         catch (ClassCastException cce)
 1429  
         {
 1430  0
             String msg = obj.getClass().getName() + " does not seem to be an User Object!";
 1431  0
             log.error(msg);
 1432  0
             throw new RuntimeException(msg);
 1433  
         }
 1434  0
         catch (Exception e)
 1435  
         {
 1436  0
             log.error(e, e);
 1437  2
         }
 1438  4
         return id;
 1439  
     }
 1440  
 
 1441  
     /**
 1442  
      * Returns the Class of the configured Object class
 1443  
      * from the peer
 1444  
      *
 1445  
      * @return The class of the objects returned by the configured peer
 1446  
      *
 1447  
      */
 1448  
 
 1449  
     private static Class getPersistenceClass()
 1450  
     {
 1451  16
         Class persistenceClass = null;
 1452  
 
 1453  
         try
 1454  
         {
 1455  16
             Object[] params = new Object[0];
 1456  
 
 1457  16
             persistenceClass =  (Class) userPeerClass
 1458  
                 .getMethod("getOMClass", null)
 1459  
                 .invoke(null, params);
 1460  8
         }
 1461  0
         catch (Exception e)
 1462  
         {
 1463  0
             persistenceClass = null;
 1464  8
         }
 1465  
 
 1466  16
         return persistenceClass;
 1467  
     }
 1468  
 
 1469  
     /**
 1470  
      * Returns a new, configured User Object with
 1471  
      * a supplied Persistent object at its core
 1472  
      *
 1473  
      * @param p The persistent object
 1474  
      *
 1475  
      * @return a new, configured User Object
 1476  
      *
 1477  
      * @exception Exception Could not create a new Object
 1478  
      *
 1479  
      */
 1480  
 
 1481  
     public static User getNewUser(Persistent p)
 1482  
     {
 1483  286
         User u = null;
 1484  
         try
 1485  
         {
 1486  286
             Class userWrapperClass = TurbineSecurity.getUserClass();
 1487  
 
 1488  286
             Class [] clazz = new Class [] { Persistent.class };
 1489  286
             Object [] params = new Object [] { p };
 1490  
 
 1491  286
             u = (User) userWrapperClass
 1492  
                 .getConstructor(clazz)
 1493  
                 .newInstance(params);
 1494  143
         }
 1495  0
         catch (Exception e)
 1496  
         {
 1497  0
             log.error("Could not instantiate a new user from supplied persistent: ", e);
 1498  143
         }
 1499  
 
 1500  286
         return u;
 1501  
     }
 1502  
 }
 1503  
 
 1504  
 

This report is generated by jcoverage, Maven and Maven JCoverage Plugin.