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