1
22
23 package com.liferay.portal.service.persistence;
24
25 import com.liferay.portal.NoSuchUserException;
26 import com.liferay.portal.SystemException;
27 import com.liferay.portal.kernel.annotation.BeanReference;
28 import com.liferay.portal.kernel.cache.CacheRegistry;
29 import com.liferay.portal.kernel.dao.jdbc.MappingSqlQuery;
30 import com.liferay.portal.kernel.dao.jdbc.MappingSqlQueryFactoryUtil;
31 import com.liferay.portal.kernel.dao.jdbc.RowMapper;
32 import com.liferay.portal.kernel.dao.jdbc.SqlUpdate;
33 import com.liferay.portal.kernel.dao.jdbc.SqlUpdateFactoryUtil;
34 import com.liferay.portal.kernel.dao.orm.DynamicQuery;
35 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
36 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
37 import com.liferay.portal.kernel.dao.orm.FinderPath;
38 import com.liferay.portal.kernel.dao.orm.Query;
39 import com.liferay.portal.kernel.dao.orm.QueryPos;
40 import com.liferay.portal.kernel.dao.orm.QueryUtil;
41 import com.liferay.portal.kernel.dao.orm.SQLQuery;
42 import com.liferay.portal.kernel.dao.orm.Session;
43 import com.liferay.portal.kernel.dao.orm.Type;
44 import com.liferay.portal.kernel.log.Log;
45 import com.liferay.portal.kernel.log.LogFactoryUtil;
46 import com.liferay.portal.kernel.util.GetterUtil;
47 import com.liferay.portal.kernel.util.OrderByComparator;
48 import com.liferay.portal.kernel.util.SetUtil;
49 import com.liferay.portal.kernel.util.StringPool;
50 import com.liferay.portal.kernel.util.StringUtil;
51 import com.liferay.portal.kernel.util.Validator;
52 import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
53 import com.liferay.portal.model.ModelListener;
54 import com.liferay.portal.model.User;
55 import com.liferay.portal.model.impl.UserImpl;
56 import com.liferay.portal.model.impl.UserModelImpl;
57 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
58
59 import java.sql.Types;
60
61 import java.util.ArrayList;
62 import java.util.Collections;
63 import java.util.List;
64 import java.util.Set;
65
66
79 public class UserPersistenceImpl extends BasePersistenceImpl
80 implements UserPersistence {
81 public static final String FINDER_CLASS_NAME_ENTITY = UserImpl.class.getName();
82 public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
83 ".List";
84 public static final FinderPath FINDER_PATH_FIND_BY_UUID = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
85 UserModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
86 "findByUuid", new String[] { String.class.getName() });
87 public static final FinderPath FINDER_PATH_FIND_BY_OBC_UUID = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
88 UserModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
89 "findByUuid",
90 new String[] {
91 String.class.getName(),
92
93 "java.lang.Integer", "java.lang.Integer",
94 "com.liferay.portal.kernel.util.OrderByComparator"
95 });
96 public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
97 UserModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
98 "countByUuid", new String[] { String.class.getName() });
99 public static final FinderPath FINDER_PATH_FIND_BY_COMPANYID = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
100 UserModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
101 "findByCompanyId", new String[] { Long.class.getName() });
102 public static final FinderPath FINDER_PATH_FIND_BY_OBC_COMPANYID = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
103 UserModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
104 "findByCompanyId",
105 new String[] {
106 Long.class.getName(),
107
108 "java.lang.Integer", "java.lang.Integer",
109 "com.liferay.portal.kernel.util.OrderByComparator"
110 });
111 public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
112 UserModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
113 "countByCompanyId", new String[] { Long.class.getName() });
114 public static final FinderPath FINDER_PATH_FETCH_BY_CONTACTID = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
115 UserModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_ENTITY,
116 "fetchByContactId", new String[] { Long.class.getName() });
117 public static final FinderPath FINDER_PATH_COUNT_BY_CONTACTID = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
118 UserModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
119 "countByContactId", new String[] { Long.class.getName() });
120 public static final FinderPath FINDER_PATH_FIND_BY_EMAILADDRESS = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
121 UserModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
122 "findByEmailAddress", new String[] { String.class.getName() });
123 public static final FinderPath FINDER_PATH_FIND_BY_OBC_EMAILADDRESS = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
124 UserModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
125 "findByEmailAddress",
126 new String[] {
127 String.class.getName(),
128
129 "java.lang.Integer", "java.lang.Integer",
130 "com.liferay.portal.kernel.util.OrderByComparator"
131 });
132 public static final FinderPath FINDER_PATH_COUNT_BY_EMAILADDRESS = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
133 UserModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
134 "countByEmailAddress", new String[] { String.class.getName() });
135 public static final FinderPath FINDER_PATH_FETCH_BY_OPENID = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
136 UserModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_ENTITY,
137 "fetchByOpenId", new String[] { String.class.getName() });
138 public static final FinderPath FINDER_PATH_COUNT_BY_OPENID = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
139 UserModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
140 "countByOpenId", new String[] { String.class.getName() });
141 public static final FinderPath FINDER_PATH_FETCH_BY_PORTRAITID = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
142 UserModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_ENTITY,
143 "fetchByPortraitId", new String[] { Long.class.getName() });
144 public static final FinderPath FINDER_PATH_COUNT_BY_PORTRAITID = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
145 UserModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
146 "countByPortraitId", new String[] { Long.class.getName() });
147 public static final FinderPath FINDER_PATH_FETCH_BY_C_U = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
148 UserModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_ENTITY,
149 "fetchByC_U",
150 new String[] { Long.class.getName(), Long.class.getName() });
151 public static final FinderPath FINDER_PATH_COUNT_BY_C_U = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
152 UserModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
153 "countByC_U",
154 new String[] { Long.class.getName(), Long.class.getName() });
155 public static final FinderPath FINDER_PATH_FETCH_BY_C_DU = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
156 UserModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_ENTITY,
157 "fetchByC_DU",
158 new String[] { Long.class.getName(), Boolean.class.getName() });
159 public static final FinderPath FINDER_PATH_COUNT_BY_C_DU = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
160 UserModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
161 "countByC_DU",
162 new String[] { Long.class.getName(), Boolean.class.getName() });
163 public static final FinderPath FINDER_PATH_FETCH_BY_C_SN = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
164 UserModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_ENTITY,
165 "fetchByC_SN",
166 new String[] { Long.class.getName(), String.class.getName() });
167 public static final FinderPath FINDER_PATH_COUNT_BY_C_SN = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
168 UserModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
169 "countByC_SN",
170 new String[] { Long.class.getName(), String.class.getName() });
171 public static final FinderPath FINDER_PATH_FETCH_BY_C_EA = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
172 UserModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_ENTITY,
173 "fetchByC_EA",
174 new String[] { Long.class.getName(), String.class.getName() });
175 public static final FinderPath FINDER_PATH_COUNT_BY_C_EA = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
176 UserModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
177 "countByC_EA",
178 new String[] { Long.class.getName(), String.class.getName() });
179 public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
180 UserModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
181 "findAll", new String[0]);
182 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
183 UserModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
184 "countAll", new String[0]);
185
186 public void cacheResult(User user) {
187 EntityCacheUtil.putResult(UserModelImpl.ENTITY_CACHE_ENABLED,
188 UserImpl.class, user.getPrimaryKey(), user);
189
190 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_CONTACTID,
191 new Object[] { new Long(user.getContactId()) }, user);
192
193 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_OPENID,
194 new Object[] { user.getOpenId() }, user);
195
196 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_PORTRAITID,
197 new Object[] { new Long(user.getPortraitId()) }, user);
198
199 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_U,
200 new Object[] {
201 new Long(user.getCompanyId()), new Long(user.getUserId())
202 }, user);
203
204 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_DU,
205 new Object[] {
206 new Long(user.getCompanyId()),
207 Boolean.valueOf(user.getDefaultUser())
208 }, user);
209
210 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_SN,
211 new Object[] { new Long(user.getCompanyId()), user.getScreenName() },
212 user);
213
214 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_EA,
215 new Object[] { new Long(user.getCompanyId()), user.getEmailAddress() },
216 user);
217 }
218
219 public void cacheResult(List<User> users) {
220 for (User user : users) {
221 if (EntityCacheUtil.getResult(UserModelImpl.ENTITY_CACHE_ENABLED,
222 UserImpl.class, user.getPrimaryKey(), this) == null) {
223 cacheResult(user);
224 }
225 }
226 }
227
228 public void clearCache() {
229 CacheRegistry.clear(UserImpl.class.getName());
230 EntityCacheUtil.clearCache(UserImpl.class.getName());
231 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
232 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
233 }
234
235 public User create(long userId) {
236 User user = new UserImpl();
237
238 user.setNew(true);
239 user.setPrimaryKey(userId);
240
241 String uuid = PortalUUIDUtil.generate();
242
243 user.setUuid(uuid);
244
245 return user;
246 }
247
248 public User remove(long userId) throws NoSuchUserException, SystemException {
249 Session session = null;
250
251 try {
252 session = openSession();
253
254 User user = (User)session.get(UserImpl.class, new Long(userId));
255
256 if (user == null) {
257 if (_log.isWarnEnabled()) {
258 _log.warn("No User exists with the primary key " + userId);
259 }
260
261 throw new NoSuchUserException(
262 "No User exists with the primary key " + userId);
263 }
264
265 return remove(user);
266 }
267 catch (NoSuchUserException nsee) {
268 throw nsee;
269 }
270 catch (Exception e) {
271 throw processException(e);
272 }
273 finally {
274 closeSession(session);
275 }
276 }
277
278 public User remove(User user) throws SystemException {
279 for (ModelListener<User> listener : listeners) {
280 listener.onBeforeRemove(user);
281 }
282
283 user = removeImpl(user);
284
285 for (ModelListener<User> listener : listeners) {
286 listener.onAfterRemove(user);
287 }
288
289 return user;
290 }
291
292 protected User removeImpl(User user) throws SystemException {
293 user = toUnwrappedModel(user);
294
295 try {
296 clearGroups.clear(user.getPrimaryKey());
297 }
298 catch (Exception e) {
299 throw processException(e);
300 }
301 finally {
302 FinderCacheUtil.clearCache("Users_Groups");
303 }
304
305 try {
306 clearOrganizations.clear(user.getPrimaryKey());
307 }
308 catch (Exception e) {
309 throw processException(e);
310 }
311 finally {
312 FinderCacheUtil.clearCache("Users_Orgs");
313 }
314
315 try {
316 clearPermissions.clear(user.getPrimaryKey());
317 }
318 catch (Exception e) {
319 throw processException(e);
320 }
321 finally {
322 FinderCacheUtil.clearCache("Users_Permissions");
323 }
324
325 try {
326 clearRoles.clear(user.getPrimaryKey());
327 }
328 catch (Exception e) {
329 throw processException(e);
330 }
331 finally {
332 FinderCacheUtil.clearCache("Users_Roles");
333 }
334
335 try {
336 clearUserGroups.clear(user.getPrimaryKey());
337 }
338 catch (Exception e) {
339 throw processException(e);
340 }
341 finally {
342 FinderCacheUtil.clearCache("Users_UserGroups");
343 }
344
345 Session session = null;
346
347 try {
348 session = openSession();
349
350 if (user.isCachedModel() || BatchSessionUtil.isEnabled()) {
351 Object staleObject = session.get(UserImpl.class,
352 user.getPrimaryKeyObj());
353
354 if (staleObject != null) {
355 session.evict(staleObject);
356 }
357 }
358
359 session.delete(user);
360
361 session.flush();
362 }
363 catch (Exception e) {
364 throw processException(e);
365 }
366 finally {
367 closeSession(session);
368 }
369
370 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
371
372 UserModelImpl userModelImpl = (UserModelImpl)user;
373
374 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_CONTACTID,
375 new Object[] { new Long(userModelImpl.getOriginalContactId()) });
376
377 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_OPENID,
378 new Object[] { userModelImpl.getOriginalOpenId() });
379
380 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_PORTRAITID,
381 new Object[] { new Long(userModelImpl.getOriginalPortraitId()) });
382
383 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_U,
384 new Object[] {
385 new Long(userModelImpl.getOriginalCompanyId()),
386 new Long(userModelImpl.getOriginalUserId())
387 });
388
389 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_DU,
390 new Object[] {
391 new Long(userModelImpl.getOriginalCompanyId()),
392 Boolean.valueOf(userModelImpl.getOriginalDefaultUser())
393 });
394
395 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_SN,
396 new Object[] {
397 new Long(userModelImpl.getOriginalCompanyId()),
398
399 userModelImpl.getOriginalScreenName()
400 });
401
402 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_EA,
403 new Object[] {
404 new Long(userModelImpl.getOriginalCompanyId()),
405
406 userModelImpl.getOriginalEmailAddress()
407 });
408
409 EntityCacheUtil.removeResult(UserModelImpl.ENTITY_CACHE_ENABLED,
410 UserImpl.class, user.getPrimaryKey());
411
412 return user;
413 }
414
415
418 public User update(User user) throws SystemException {
419 if (_log.isWarnEnabled()) {
420 _log.warn(
421 "Using the deprecated update(User user) method. Use update(User user, boolean merge) instead.");
422 }
423
424 return update(user, false);
425 }
426
427
439 public User update(User user, boolean merge) throws SystemException {
440 boolean isNew = user.isNew();
441
442 for (ModelListener<User> listener : listeners) {
443 if (isNew) {
444 listener.onBeforeCreate(user);
445 }
446 else {
447 listener.onBeforeUpdate(user);
448 }
449 }
450
451 user = updateImpl(user, merge);
452
453 for (ModelListener<User> listener : listeners) {
454 if (isNew) {
455 listener.onAfterCreate(user);
456 }
457 else {
458 listener.onAfterUpdate(user);
459 }
460 }
461
462 return user;
463 }
464
465 public User updateImpl(com.liferay.portal.model.User user, boolean merge)
466 throws SystemException {
467 user = toUnwrappedModel(user);
468
469 boolean isNew = user.isNew();
470
471 UserModelImpl userModelImpl = (UserModelImpl)user;
472
473 if (Validator.isNull(user.getUuid())) {
474 String uuid = PortalUUIDUtil.generate();
475
476 user.setUuid(uuid);
477 }
478
479 Session session = null;
480
481 try {
482 session = openSession();
483
484 BatchSessionUtil.update(session, user, merge);
485
486 user.setNew(false);
487 }
488 catch (Exception e) {
489 throw processException(e);
490 }
491 finally {
492 closeSession(session);
493 }
494
495 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
496
497 EntityCacheUtil.putResult(UserModelImpl.ENTITY_CACHE_ENABLED,
498 UserImpl.class, user.getPrimaryKey(), user);
499
500 if (!isNew &&
501 (user.getContactId() != userModelImpl.getOriginalContactId())) {
502 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_CONTACTID,
503 new Object[] { new Long(userModelImpl.getOriginalContactId()) });
504 }
505
506 if (isNew ||
507 (user.getContactId() != userModelImpl.getOriginalContactId())) {
508 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_CONTACTID,
509 new Object[] { new Long(user.getContactId()) }, user);
510 }
511
512 if (!isNew &&
513 (!Validator.equals(user.getOpenId(),
514 userModelImpl.getOriginalOpenId()))) {
515 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_OPENID,
516 new Object[] { userModelImpl.getOriginalOpenId() });
517 }
518
519 if (isNew ||
520 (!Validator.equals(user.getOpenId(),
521 userModelImpl.getOriginalOpenId()))) {
522 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_OPENID,
523 new Object[] { user.getOpenId() }, user);
524 }
525
526 if (!isNew &&
527 (user.getPortraitId() != userModelImpl.getOriginalPortraitId())) {
528 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_PORTRAITID,
529 new Object[] { new Long(userModelImpl.getOriginalPortraitId()) });
530 }
531
532 if (isNew ||
533 (user.getPortraitId() != userModelImpl.getOriginalPortraitId())) {
534 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_PORTRAITID,
535 new Object[] { new Long(user.getPortraitId()) }, user);
536 }
537
538 if (!isNew &&
539 ((user.getCompanyId() != userModelImpl.getOriginalCompanyId()) ||
540 (user.getUserId() != userModelImpl.getOriginalUserId()))) {
541 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_U,
542 new Object[] {
543 new Long(userModelImpl.getOriginalCompanyId()),
544 new Long(userModelImpl.getOriginalUserId())
545 });
546 }
547
548 if (isNew ||
549 ((user.getCompanyId() != userModelImpl.getOriginalCompanyId()) ||
550 (user.getUserId() != userModelImpl.getOriginalUserId()))) {
551 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_U,
552 new Object[] {
553 new Long(user.getCompanyId()), new Long(user.getUserId())
554 }, user);
555 }
556
557 if (!isNew &&
558 ((user.getCompanyId() != userModelImpl.getOriginalCompanyId()) ||
559 (user.getDefaultUser() != userModelImpl.getOriginalDefaultUser()))) {
560 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_DU,
561 new Object[] {
562 new Long(userModelImpl.getOriginalCompanyId()),
563 Boolean.valueOf(userModelImpl.getOriginalDefaultUser())
564 });
565 }
566
567 if (isNew ||
568 ((user.getCompanyId() != userModelImpl.getOriginalCompanyId()) ||
569 (user.getDefaultUser() != userModelImpl.getOriginalDefaultUser()))) {
570 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_DU,
571 new Object[] {
572 new Long(user.getCompanyId()),
573 Boolean.valueOf(user.getDefaultUser())
574 }, user);
575 }
576
577 if (!isNew &&
578 ((user.getCompanyId() != userModelImpl.getOriginalCompanyId()) ||
579 !Validator.equals(user.getScreenName(),
580 userModelImpl.getOriginalScreenName()))) {
581 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_SN,
582 new Object[] {
583 new Long(userModelImpl.getOriginalCompanyId()),
584
585 userModelImpl.getOriginalScreenName()
586 });
587 }
588
589 if (isNew ||
590 ((user.getCompanyId() != userModelImpl.getOriginalCompanyId()) ||
591 !Validator.equals(user.getScreenName(),
592 userModelImpl.getOriginalScreenName()))) {
593 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_SN,
594 new Object[] { new Long(user.getCompanyId()), user.getScreenName() },
595 user);
596 }
597
598 if (!isNew &&
599 ((user.getCompanyId() != userModelImpl.getOriginalCompanyId()) ||
600 !Validator.equals(user.getEmailAddress(),
601 userModelImpl.getOriginalEmailAddress()))) {
602 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_EA,
603 new Object[] {
604 new Long(userModelImpl.getOriginalCompanyId()),
605
606 userModelImpl.getOriginalEmailAddress()
607 });
608 }
609
610 if (isNew ||
611 ((user.getCompanyId() != userModelImpl.getOriginalCompanyId()) ||
612 !Validator.equals(user.getEmailAddress(),
613 userModelImpl.getOriginalEmailAddress()))) {
614 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_EA,
615 new Object[] {
616 new Long(user.getCompanyId()),
617
618 user.getEmailAddress()
619 }, user);
620 }
621
622 return user;
623 }
624
625 protected User toUnwrappedModel(User user) {
626 if (user instanceof UserImpl) {
627 return user;
628 }
629
630 UserImpl userImpl = new UserImpl();
631
632 userImpl.setNew(user.isNew());
633 userImpl.setPrimaryKey(user.getPrimaryKey());
634
635 userImpl.setUuid(user.getUuid());
636 userImpl.setUserId(user.getUserId());
637 userImpl.setCompanyId(user.getCompanyId());
638 userImpl.setCreateDate(user.getCreateDate());
639 userImpl.setModifiedDate(user.getModifiedDate());
640 userImpl.setDefaultUser(user.isDefaultUser());
641 userImpl.setContactId(user.getContactId());
642 userImpl.setPassword(user.getPassword());
643 userImpl.setPasswordEncrypted(user.isPasswordEncrypted());
644 userImpl.setPasswordReset(user.isPasswordReset());
645 userImpl.setPasswordModifiedDate(user.getPasswordModifiedDate());
646 userImpl.setReminderQueryQuestion(user.getReminderQueryQuestion());
647 userImpl.setReminderQueryAnswer(user.getReminderQueryAnswer());
648 userImpl.setGraceLoginCount(user.getGraceLoginCount());
649 userImpl.setScreenName(user.getScreenName());
650 userImpl.setEmailAddress(user.getEmailAddress());
651 userImpl.setOpenId(user.getOpenId());
652 userImpl.setPortraitId(user.getPortraitId());
653 userImpl.setLanguageId(user.getLanguageId());
654 userImpl.setTimeZoneId(user.getTimeZoneId());
655 userImpl.setGreeting(user.getGreeting());
656 userImpl.setComments(user.getComments());
657 userImpl.setFirstName(user.getFirstName());
658 userImpl.setMiddleName(user.getMiddleName());
659 userImpl.setLastName(user.getLastName());
660 userImpl.setJobTitle(user.getJobTitle());
661 userImpl.setLoginDate(user.getLoginDate());
662 userImpl.setLoginIP(user.getLoginIP());
663 userImpl.setLastLoginDate(user.getLastLoginDate());
664 userImpl.setLastLoginIP(user.getLastLoginIP());
665 userImpl.setLastFailedLoginDate(user.getLastFailedLoginDate());
666 userImpl.setFailedLoginAttempts(user.getFailedLoginAttempts());
667 userImpl.setLockout(user.isLockout());
668 userImpl.setLockoutDate(user.getLockoutDate());
669 userImpl.setAgreedToTermsOfUse(user.isAgreedToTermsOfUse());
670 userImpl.setActive(user.isActive());
671
672 return userImpl;
673 }
674
675 public User findByPrimaryKey(long userId)
676 throws NoSuchUserException, SystemException {
677 User user = fetchByPrimaryKey(userId);
678
679 if (user == null) {
680 if (_log.isWarnEnabled()) {
681 _log.warn("No User exists with the primary key " + userId);
682 }
683
684 throw new NoSuchUserException(
685 "No User exists with the primary key " + userId);
686 }
687
688 return user;
689 }
690
691 public User fetchByPrimaryKey(long userId) throws SystemException {
692 User user = (User)EntityCacheUtil.getResult(UserModelImpl.ENTITY_CACHE_ENABLED,
693 UserImpl.class, userId, this);
694
695 if (user == null) {
696 Session session = null;
697
698 try {
699 session = openSession();
700
701 user = (User)session.get(UserImpl.class, new Long(userId));
702 }
703 catch (Exception e) {
704 throw processException(e);
705 }
706 finally {
707 if (user != null) {
708 cacheResult(user);
709 }
710
711 closeSession(session);
712 }
713 }
714
715 return user;
716 }
717
718 public List<User> findByUuid(String uuid) throws SystemException {
719 Object[] finderArgs = new Object[] { uuid };
720
721 List<User> list = (List<User>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_UUID,
722 finderArgs, this);
723
724 if (list == null) {
725 Session session = null;
726
727 try {
728 session = openSession();
729
730 StringBuilder query = new StringBuilder();
731
732 query.append("SELECT user FROM User user WHERE ");
733
734 if (uuid == null) {
735 query.append("user.uuid IS NULL");
736 }
737 else {
738 query.append("user.uuid = ?");
739 }
740
741 query.append(" ");
742
743 Query q = session.createQuery(query.toString());
744
745 QueryPos qPos = QueryPos.getInstance(q);
746
747 if (uuid != null) {
748 qPos.add(uuid);
749 }
750
751 list = q.list();
752 }
753 catch (Exception e) {
754 throw processException(e);
755 }
756 finally {
757 if (list == null) {
758 list = new ArrayList<User>();
759 }
760
761 cacheResult(list);
762
763 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_UUID, finderArgs,
764 list);
765
766 closeSession(session);
767 }
768 }
769
770 return list;
771 }
772
773 public List<User> findByUuid(String uuid, int start, int end)
774 throws SystemException {
775 return findByUuid(uuid, start, end, null);
776 }
777
778 public List<User> findByUuid(String uuid, int start, int end,
779 OrderByComparator obc) throws SystemException {
780 Object[] finderArgs = new Object[] {
781 uuid,
782
783 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
784 };
785
786 List<User> list = (List<User>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_UUID,
787 finderArgs, this);
788
789 if (list == null) {
790 Session session = null;
791
792 try {
793 session = openSession();
794
795 StringBuilder query = new StringBuilder();
796
797 query.append("SELECT user FROM User user WHERE ");
798
799 if (uuid == null) {
800 query.append("user.uuid IS NULL");
801 }
802 else {
803 query.append("user.uuid = ?");
804 }
805
806 query.append(" ");
807
808 if (obc != null) {
809 query.append("ORDER BY ");
810
811 String[] orderByFields = obc.getOrderByFields();
812
813 for (int i = 0; i < orderByFields.length; i++) {
814 query.append("user.");
815 query.append(orderByFields[i]);
816
817 if (obc.isAscending()) {
818 query.append(" ASC");
819 }
820 else {
821 query.append(" DESC");
822 }
823
824 if ((i + 1) < orderByFields.length) {
825 query.append(", ");
826 }
827 }
828 }
829
830 Query q = session.createQuery(query.toString());
831
832 QueryPos qPos = QueryPos.getInstance(q);
833
834 if (uuid != null) {
835 qPos.add(uuid);
836 }
837
838 list = (List<User>)QueryUtil.list(q, getDialect(), start, end);
839 }
840 catch (Exception e) {
841 throw processException(e);
842 }
843 finally {
844 if (list == null) {
845 list = new ArrayList<User>();
846 }
847
848 cacheResult(list);
849
850 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_UUID,
851 finderArgs, list);
852
853 closeSession(session);
854 }
855 }
856
857 return list;
858 }
859
860 public User findByUuid_First(String uuid, OrderByComparator obc)
861 throws NoSuchUserException, SystemException {
862 List<User> list = findByUuid(uuid, 0, 1, obc);
863
864 if (list.isEmpty()) {
865 StringBuilder msg = new StringBuilder();
866
867 msg.append("No User exists with the key {");
868
869 msg.append("uuid=" + uuid);
870
871 msg.append(StringPool.CLOSE_CURLY_BRACE);
872
873 throw new NoSuchUserException(msg.toString());
874 }
875 else {
876 return list.get(0);
877 }
878 }
879
880 public User findByUuid_Last(String uuid, OrderByComparator obc)
881 throws NoSuchUserException, SystemException {
882 int count = countByUuid(uuid);
883
884 List<User> list = findByUuid(uuid, count - 1, count, obc);
885
886 if (list.isEmpty()) {
887 StringBuilder msg = new StringBuilder();
888
889 msg.append("No User exists with the key {");
890
891 msg.append("uuid=" + uuid);
892
893 msg.append(StringPool.CLOSE_CURLY_BRACE);
894
895 throw new NoSuchUserException(msg.toString());
896 }
897 else {
898 return list.get(0);
899 }
900 }
901
902 public User[] findByUuid_PrevAndNext(long userId, String uuid,
903 OrderByComparator obc) throws NoSuchUserException, SystemException {
904 User user = findByPrimaryKey(userId);
905
906 int count = countByUuid(uuid);
907
908 Session session = null;
909
910 try {
911 session = openSession();
912
913 StringBuilder query = new StringBuilder();
914
915 query.append("SELECT user FROM User user WHERE ");
916
917 if (uuid == null) {
918 query.append("user.uuid IS NULL");
919 }
920 else {
921 query.append("user.uuid = ?");
922 }
923
924 query.append(" ");
925
926 if (obc != null) {
927 query.append("ORDER BY ");
928
929 String[] orderByFields = obc.getOrderByFields();
930
931 for (int i = 0; i < orderByFields.length; i++) {
932 query.append("user.");
933 query.append(orderByFields[i]);
934
935 if (obc.isAscending()) {
936 query.append(" ASC");
937 }
938 else {
939 query.append(" DESC");
940 }
941
942 if ((i + 1) < orderByFields.length) {
943 query.append(", ");
944 }
945 }
946 }
947
948 Query q = session.createQuery(query.toString());
949
950 QueryPos qPos = QueryPos.getInstance(q);
951
952 if (uuid != null) {
953 qPos.add(uuid);
954 }
955
956 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc, user);
957
958 User[] array = new UserImpl[3];
959
960 array[0] = (User)objArray[0];
961 array[1] = (User)objArray[1];
962 array[2] = (User)objArray[2];
963
964 return array;
965 }
966 catch (Exception e) {
967 throw processException(e);
968 }
969 finally {
970 closeSession(session);
971 }
972 }
973
974 public List<User> findByCompanyId(long companyId) throws SystemException {
975 Object[] finderArgs = new Object[] { new Long(companyId) };
976
977 List<User> list = (List<User>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_COMPANYID,
978 finderArgs, this);
979
980 if (list == null) {
981 Session session = null;
982
983 try {
984 session = openSession();
985
986 StringBuilder query = new StringBuilder();
987
988 query.append("SELECT user FROM User user WHERE ");
989
990 query.append("user.companyId = ?");
991
992 query.append(" ");
993
994 Query q = session.createQuery(query.toString());
995
996 QueryPos qPos = QueryPos.getInstance(q);
997
998 qPos.add(companyId);
999
1000 list = q.list();
1001 }
1002 catch (Exception e) {
1003 throw processException(e);
1004 }
1005 finally {
1006 if (list == null) {
1007 list = new ArrayList<User>();
1008 }
1009
1010 cacheResult(list);
1011
1012 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_COMPANYID,
1013 finderArgs, list);
1014
1015 closeSession(session);
1016 }
1017 }
1018
1019 return list;
1020 }
1021
1022 public List<User> findByCompanyId(long companyId, int start, int end)
1023 throws SystemException {
1024 return findByCompanyId(companyId, start, end, null);
1025 }
1026
1027 public List<User> findByCompanyId(long companyId, int start, int end,
1028 OrderByComparator obc) throws SystemException {
1029 Object[] finderArgs = new Object[] {
1030 new Long(companyId),
1031
1032 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
1033 };
1034
1035 List<User> list = (List<User>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_COMPANYID,
1036 finderArgs, this);
1037
1038 if (list == null) {
1039 Session session = null;
1040
1041 try {
1042 session = openSession();
1043
1044 StringBuilder query = new StringBuilder();
1045
1046 query.append("SELECT user FROM User user WHERE ");
1047
1048 query.append("user.companyId = ?");
1049
1050 query.append(" ");
1051
1052 if (obc != null) {
1053 query.append("ORDER BY ");
1054
1055 String[] orderByFields = obc.getOrderByFields();
1056
1057 for (int i = 0; i < orderByFields.length; i++) {
1058 query.append("user.");
1059 query.append(orderByFields[i]);
1060
1061 if (obc.isAscending()) {
1062 query.append(" ASC");
1063 }
1064 else {
1065 query.append(" DESC");
1066 }
1067
1068 if ((i + 1) < orderByFields.length) {
1069 query.append(", ");
1070 }
1071 }
1072 }
1073
1074 Query q = session.createQuery(query.toString());
1075
1076 QueryPos qPos = QueryPos.getInstance(q);
1077
1078 qPos.add(companyId);
1079
1080 list = (List<User>)QueryUtil.list(q, getDialect(), start, end);
1081 }
1082 catch (Exception e) {
1083 throw processException(e);
1084 }
1085 finally {
1086 if (list == null) {
1087 list = new ArrayList<User>();
1088 }
1089
1090 cacheResult(list);
1091
1092 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_COMPANYID,
1093 finderArgs, list);
1094
1095 closeSession(session);
1096 }
1097 }
1098
1099 return list;
1100 }
1101
1102 public User findByCompanyId_First(long companyId, OrderByComparator obc)
1103 throws NoSuchUserException, SystemException {
1104 List<User> list = findByCompanyId(companyId, 0, 1, obc);
1105
1106 if (list.isEmpty()) {
1107 StringBuilder msg = new StringBuilder();
1108
1109 msg.append("No User exists with the key {");
1110
1111 msg.append("companyId=" + companyId);
1112
1113 msg.append(StringPool.CLOSE_CURLY_BRACE);
1114
1115 throw new NoSuchUserException(msg.toString());
1116 }
1117 else {
1118 return list.get(0);
1119 }
1120 }
1121
1122 public User findByCompanyId_Last(long companyId, OrderByComparator obc)
1123 throws NoSuchUserException, SystemException {
1124 int count = countByCompanyId(companyId);
1125
1126 List<User> list = findByCompanyId(companyId, count - 1, count, obc);
1127
1128 if (list.isEmpty()) {
1129 StringBuilder msg = new StringBuilder();
1130
1131 msg.append("No User exists with the key {");
1132
1133 msg.append("companyId=" + companyId);
1134
1135 msg.append(StringPool.CLOSE_CURLY_BRACE);
1136
1137 throw new NoSuchUserException(msg.toString());
1138 }
1139 else {
1140 return list.get(0);
1141 }
1142 }
1143
1144 public User[] findByCompanyId_PrevAndNext(long userId, long companyId,
1145 OrderByComparator obc) throws NoSuchUserException, SystemException {
1146 User user = findByPrimaryKey(userId);
1147
1148 int count = countByCompanyId(companyId);
1149
1150 Session session = null;
1151
1152 try {
1153 session = openSession();
1154
1155 StringBuilder query = new StringBuilder();
1156
1157 query.append("SELECT user FROM User user WHERE ");
1158
1159 query.append("user.companyId = ?");
1160
1161 query.append(" ");
1162
1163 if (obc != null) {
1164 query.append("ORDER BY ");
1165
1166 String[] orderByFields = obc.getOrderByFields();
1167
1168 for (int i = 0; i < orderByFields.length; i++) {
1169 query.append("user.");
1170 query.append(orderByFields[i]);
1171
1172 if (obc.isAscending()) {
1173 query.append(" ASC");
1174 }
1175 else {
1176 query.append(" DESC");
1177 }
1178
1179 if ((i + 1) < orderByFields.length) {
1180 query.append(", ");
1181 }
1182 }
1183 }
1184
1185 Query q = session.createQuery(query.toString());
1186
1187 QueryPos qPos = QueryPos.getInstance(q);
1188
1189 qPos.add(companyId);
1190
1191 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc, user);
1192
1193 User[] array = new UserImpl[3];
1194
1195 array[0] = (User)objArray[0];
1196 array[1] = (User)objArray[1];
1197 array[2] = (User)objArray[2];
1198
1199 return array;
1200 }
1201 catch (Exception e) {
1202 throw processException(e);
1203 }
1204 finally {
1205 closeSession(session);
1206 }
1207 }
1208
1209 public User findByContactId(long contactId)
1210 throws NoSuchUserException, SystemException {
1211 User user = fetchByContactId(contactId);
1212
1213 if (user == null) {
1214 StringBuilder msg = new StringBuilder();
1215
1216 msg.append("No User exists with the key {");
1217
1218 msg.append("contactId=" + contactId);
1219
1220 msg.append(StringPool.CLOSE_CURLY_BRACE);
1221
1222 if (_log.isWarnEnabled()) {
1223 _log.warn(msg.toString());
1224 }
1225
1226 throw new NoSuchUserException(msg.toString());
1227 }
1228
1229 return user;
1230 }
1231
1232 public User fetchByContactId(long contactId) throws SystemException {
1233 return fetchByContactId(contactId, true);
1234 }
1235
1236 public User fetchByContactId(long contactId, boolean retrieveFromCache)
1237 throws SystemException {
1238 Object[] finderArgs = new Object[] { new Long(contactId) };
1239
1240 Object result = null;
1241
1242 if (retrieveFromCache) {
1243 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_CONTACTID,
1244 finderArgs, this);
1245 }
1246
1247 if (result == null) {
1248 Session session = null;
1249
1250 try {
1251 session = openSession();
1252
1253 StringBuilder query = new StringBuilder();
1254
1255 query.append("SELECT user FROM User user WHERE ");
1256
1257 query.append("user.contactId = ?");
1258
1259 query.append(" ");
1260
1261 Query q = session.createQuery(query.toString());
1262
1263 QueryPos qPos = QueryPos.getInstance(q);
1264
1265 qPos.add(contactId);
1266
1267 List<User> list = q.list();
1268
1269 result = list;
1270
1271 User user = null;
1272
1273 if (list.isEmpty()) {
1274 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_CONTACTID,
1275 finderArgs, list);
1276 }
1277 else {
1278 user = list.get(0);
1279
1280 cacheResult(user);
1281
1282 if ((user.getContactId() != contactId)) {
1283 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_CONTACTID,
1284 finderArgs, user);
1285 }
1286 }
1287
1288 return user;
1289 }
1290 catch (Exception e) {
1291 throw processException(e);
1292 }
1293 finally {
1294 if (result == null) {
1295 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_CONTACTID,
1296 finderArgs, new ArrayList<User>());
1297 }
1298
1299 closeSession(session);
1300 }
1301 }
1302 else {
1303 if (result instanceof List<?>) {
1304 return null;
1305 }
1306 else {
1307 return (User)result;
1308 }
1309 }
1310 }
1311
1312 public List<User> findByEmailAddress(String emailAddress)
1313 throws SystemException {
1314 Object[] finderArgs = new Object[] { emailAddress };
1315
1316 List<User> list = (List<User>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_EMAILADDRESS,
1317 finderArgs, this);
1318
1319 if (list == null) {
1320 Session session = null;
1321
1322 try {
1323 session = openSession();
1324
1325 StringBuilder query = new StringBuilder();
1326
1327 query.append("SELECT user FROM User user WHERE ");
1328
1329 if (emailAddress == null) {
1330 query.append("user.emailAddress IS NULL");
1331 }
1332 else {
1333 query.append("user.emailAddress = ?");
1334 }
1335
1336 query.append(" ");
1337
1338 Query q = session.createQuery(query.toString());
1339
1340 QueryPos qPos = QueryPos.getInstance(q);
1341
1342 if (emailAddress != null) {
1343 qPos.add(emailAddress);
1344 }
1345
1346 list = q.list();
1347 }
1348 catch (Exception e) {
1349 throw processException(e);
1350 }
1351 finally {
1352 if (list == null) {
1353 list = new ArrayList<User>();
1354 }
1355
1356 cacheResult(list);
1357
1358 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_EMAILADDRESS,
1359 finderArgs, list);
1360
1361 closeSession(session);
1362 }
1363 }
1364
1365 return list;
1366 }
1367
1368 public List<User> findByEmailAddress(String emailAddress, int start, int end)
1369 throws SystemException {
1370 return findByEmailAddress(emailAddress, start, end, null);
1371 }
1372
1373 public List<User> findByEmailAddress(String emailAddress, int start,
1374 int end, OrderByComparator obc) throws SystemException {
1375 Object[] finderArgs = new Object[] {
1376 emailAddress,
1377
1378 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
1379 };
1380
1381 List<User> list = (List<User>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_EMAILADDRESS,
1382 finderArgs, this);
1383
1384 if (list == null) {
1385 Session session = null;
1386
1387 try {
1388 session = openSession();
1389
1390 StringBuilder query = new StringBuilder();
1391
1392 query.append("SELECT user FROM User user WHERE ");
1393
1394 if (emailAddress == null) {
1395 query.append("user.emailAddress IS NULL");
1396 }
1397 else {
1398 query.append("user.emailAddress = ?");
1399 }
1400
1401 query.append(" ");
1402
1403 if (obc != null) {
1404 query.append("ORDER BY ");
1405
1406 String[] orderByFields = obc.getOrderByFields();
1407
1408 for (int i = 0; i < orderByFields.length; i++) {
1409 query.append("user.");
1410 query.append(orderByFields[i]);
1411
1412 if (obc.isAscending()) {
1413 query.append(" ASC");
1414 }
1415 else {
1416 query.append(" DESC");
1417 }
1418
1419 if ((i + 1) < orderByFields.length) {
1420 query.append(", ");
1421 }
1422 }
1423 }
1424
1425 Query q = session.createQuery(query.toString());
1426
1427 QueryPos qPos = QueryPos.getInstance(q);
1428
1429 if (emailAddress != null) {
1430 qPos.add(emailAddress);
1431 }
1432
1433 list = (List<User>)QueryUtil.list(q, getDialect(), start, end);
1434 }
1435 catch (Exception e) {
1436 throw processException(e);
1437 }
1438 finally {
1439 if (list == null) {
1440 list = new ArrayList<User>();
1441 }
1442
1443 cacheResult(list);
1444
1445 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_EMAILADDRESS,
1446 finderArgs, list);
1447
1448 closeSession(session);
1449 }
1450 }
1451
1452 return list;
1453 }
1454
1455 public User findByEmailAddress_First(String emailAddress,
1456 OrderByComparator obc) throws NoSuchUserException, SystemException {
1457 List<User> list = findByEmailAddress(emailAddress, 0, 1, obc);
1458
1459 if (list.isEmpty()) {
1460 StringBuilder msg = new StringBuilder();
1461
1462 msg.append("No User exists with the key {");
1463
1464 msg.append("emailAddress=" + emailAddress);
1465
1466 msg.append(StringPool.CLOSE_CURLY_BRACE);
1467
1468 throw new NoSuchUserException(msg.toString());
1469 }
1470 else {
1471 return list.get(0);
1472 }
1473 }
1474
1475 public User findByEmailAddress_Last(String emailAddress,
1476 OrderByComparator obc) throws NoSuchUserException, SystemException {
1477 int count = countByEmailAddress(emailAddress);
1478
1479 List<User> list = findByEmailAddress(emailAddress, count - 1, count, obc);
1480
1481 if (list.isEmpty()) {
1482 StringBuilder msg = new StringBuilder();
1483
1484 msg.append("No User exists with the key {");
1485
1486 msg.append("emailAddress=" + emailAddress);
1487
1488 msg.append(StringPool.CLOSE_CURLY_BRACE);
1489
1490 throw new NoSuchUserException(msg.toString());
1491 }
1492 else {
1493 return list.get(0);
1494 }
1495 }
1496
1497 public User[] findByEmailAddress_PrevAndNext(long userId,
1498 String emailAddress, OrderByComparator obc)
1499 throws NoSuchUserException, SystemException {
1500 User user = findByPrimaryKey(userId);
1501
1502 int count = countByEmailAddress(emailAddress);
1503
1504 Session session = null;
1505
1506 try {
1507 session = openSession();
1508
1509 StringBuilder query = new StringBuilder();
1510
1511 query.append("SELECT user FROM User user WHERE ");
1512
1513 if (emailAddress == null) {
1514 query.append("user.emailAddress IS NULL");
1515 }
1516 else {
1517 query.append("user.emailAddress = ?");
1518 }
1519
1520 query.append(" ");
1521
1522 if (obc != null) {
1523 query.append("ORDER BY ");
1524
1525 String[] orderByFields = obc.getOrderByFields();
1526
1527 for (int i = 0; i < orderByFields.length; i++) {
1528 query.append("user.");
1529 query.append(orderByFields[i]);
1530
1531 if (obc.isAscending()) {
1532 query.append(" ASC");
1533 }
1534 else {
1535 query.append(" DESC");
1536 }
1537
1538 if ((i + 1) < orderByFields.length) {
1539 query.append(", ");
1540 }
1541 }
1542 }
1543
1544 Query q = session.createQuery(query.toString());
1545
1546 QueryPos qPos = QueryPos.getInstance(q);
1547
1548 if (emailAddress != null) {
1549 qPos.add(emailAddress);
1550 }
1551
1552 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc, user);
1553
1554 User[] array = new UserImpl[3];
1555
1556 array[0] = (User)objArray[0];
1557 array[1] = (User)objArray[1];
1558 array[2] = (User)objArray[2];
1559
1560 return array;
1561 }
1562 catch (Exception e) {
1563 throw processException(e);
1564 }
1565 finally {
1566 closeSession(session);
1567 }
1568 }
1569
1570 public User findByOpenId(String openId)
1571 throws NoSuchUserException, SystemException {
1572 User user = fetchByOpenId(openId);
1573
1574 if (user == null) {
1575 StringBuilder msg = new StringBuilder();
1576
1577 msg.append("No User exists with the key {");
1578
1579 msg.append("openId=" + openId);
1580
1581 msg.append(StringPool.CLOSE_CURLY_BRACE);
1582
1583 if (_log.isWarnEnabled()) {
1584 _log.warn(msg.toString());
1585 }
1586
1587 throw new NoSuchUserException(msg.toString());
1588 }
1589
1590 return user;
1591 }
1592
1593 public User fetchByOpenId(String openId) throws SystemException {
1594 return fetchByOpenId(openId, true);
1595 }
1596
1597 public User fetchByOpenId(String openId, boolean retrieveFromCache)
1598 throws SystemException {
1599 Object[] finderArgs = new Object[] { openId };
1600
1601 Object result = null;
1602
1603 if (retrieveFromCache) {
1604 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_OPENID,
1605 finderArgs, this);
1606 }
1607
1608 if (result == null) {
1609 Session session = null;
1610
1611 try {
1612 session = openSession();
1613
1614 StringBuilder query = new StringBuilder();
1615
1616 query.append("SELECT user FROM User user WHERE ");
1617
1618 if (openId == null) {
1619 query.append("user.openId IS NULL");
1620 }
1621 else {
1622 query.append("user.openId = ?");
1623 }
1624
1625 query.append(" ");
1626
1627 Query q = session.createQuery(query.toString());
1628
1629 QueryPos qPos = QueryPos.getInstance(q);
1630
1631 if (openId != null) {
1632 qPos.add(openId);
1633 }
1634
1635 List<User> list = q.list();
1636
1637 result = list;
1638
1639 User user = null;
1640
1641 if (list.isEmpty()) {
1642 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_OPENID,
1643 finderArgs, list);
1644 }
1645 else {
1646 user = list.get(0);
1647
1648 cacheResult(user);
1649
1650 if ((user.getOpenId() == null) ||
1651 !user.getOpenId().equals(openId)) {
1652 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_OPENID,
1653 finderArgs, user);
1654 }
1655 }
1656
1657 return user;
1658 }
1659 catch (Exception e) {
1660 throw processException(e);
1661 }
1662 finally {
1663 if (result == null) {
1664 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_OPENID,
1665 finderArgs, new ArrayList<User>());
1666 }
1667
1668 closeSession(session);
1669 }
1670 }
1671 else {
1672 if (result instanceof List<?>) {
1673 return null;
1674 }
1675 else {
1676 return (User)result;
1677 }
1678 }
1679 }
1680
1681 public User findByPortraitId(long portraitId)
1682 throws NoSuchUserException, SystemException {
1683 User user = fetchByPortraitId(portraitId);
1684
1685 if (user == null) {
1686 StringBuilder msg = new StringBuilder();
1687
1688 msg.append("No User exists with the key {");
1689
1690 msg.append("portraitId=" + portraitId);
1691
1692 msg.append(StringPool.CLOSE_CURLY_BRACE);
1693
1694 if (_log.isWarnEnabled()) {
1695 _log.warn(msg.toString());
1696 }
1697
1698 throw new NoSuchUserException(msg.toString());
1699 }
1700
1701 return user;
1702 }
1703
1704 public User fetchByPortraitId(long portraitId) throws SystemException {
1705 return fetchByPortraitId(portraitId, true);
1706 }
1707
1708 public User fetchByPortraitId(long portraitId, boolean retrieveFromCache)
1709 throws SystemException {
1710 Object[] finderArgs = new Object[] { new Long(portraitId) };
1711
1712 Object result = null;
1713
1714 if (retrieveFromCache) {
1715 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_PORTRAITID,
1716 finderArgs, this);
1717 }
1718
1719 if (result == null) {
1720 Session session = null;
1721
1722 try {
1723 session = openSession();
1724
1725 StringBuilder query = new StringBuilder();
1726
1727 query.append("SELECT user FROM User user WHERE ");
1728
1729 query.append("user.portraitId = ?");
1730
1731 query.append(" ");
1732
1733 Query q = session.createQuery(query.toString());
1734
1735 QueryPos qPos = QueryPos.getInstance(q);
1736
1737 qPos.add(portraitId);
1738
1739 List<User> list = q.list();
1740
1741 result = list;
1742
1743 User user = null;
1744
1745 if (list.isEmpty()) {
1746 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_PORTRAITID,
1747 finderArgs, list);
1748 }
1749 else {
1750 user = list.get(0);
1751
1752 cacheResult(user);
1753
1754 if ((user.getPortraitId() != portraitId)) {
1755 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_PORTRAITID,
1756 finderArgs, user);
1757 }
1758 }
1759
1760 return user;
1761 }
1762 catch (Exception e) {
1763 throw processException(e);
1764 }
1765 finally {
1766 if (result == null) {
1767 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_PORTRAITID,
1768 finderArgs, new ArrayList<User>());
1769 }
1770
1771 closeSession(session);
1772 }
1773 }
1774 else {
1775 if (result instanceof List<?>) {
1776 return null;
1777 }
1778 else {
1779 return (User)result;
1780 }
1781 }
1782 }
1783
1784 public User findByC_U(long companyId, long userId)
1785 throws NoSuchUserException, SystemException {
1786 User user = fetchByC_U(companyId, userId);
1787
1788 if (user == null) {
1789 StringBuilder msg = new StringBuilder();
1790
1791 msg.append("No User exists with the key {");
1792
1793 msg.append("companyId=" + companyId);
1794
1795 msg.append(", ");
1796 msg.append("userId=" + userId);
1797
1798 msg.append(StringPool.CLOSE_CURLY_BRACE);
1799
1800 if (_log.isWarnEnabled()) {
1801 _log.warn(msg.toString());
1802 }
1803
1804 throw new NoSuchUserException(msg.toString());
1805 }
1806
1807 return user;
1808 }
1809
1810 public User fetchByC_U(long companyId, long userId)
1811 throws SystemException {
1812 return fetchByC_U(companyId, userId, true);
1813 }
1814
1815 public User fetchByC_U(long companyId, long userId,
1816 boolean retrieveFromCache) throws SystemException {
1817 Object[] finderArgs = new Object[] { new Long(companyId), new Long(userId) };
1818
1819 Object result = null;
1820
1821 if (retrieveFromCache) {
1822 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_U,
1823 finderArgs, this);
1824 }
1825
1826 if (result == null) {
1827 Session session = null;
1828
1829 try {
1830 session = openSession();
1831
1832 StringBuilder query = new StringBuilder();
1833
1834 query.append("SELECT user FROM User user WHERE ");
1835
1836 query.append("user.companyId = ?");
1837
1838 query.append(" AND ");
1839
1840 query.append("user.userId = ?");
1841
1842 query.append(" ");
1843
1844 Query q = session.createQuery(query.toString());
1845
1846 QueryPos qPos = QueryPos.getInstance(q);
1847
1848 qPos.add(companyId);
1849
1850 qPos.add(userId);
1851
1852 List<User> list = q.list();
1853
1854 result = list;
1855
1856 User user = null;
1857
1858 if (list.isEmpty()) {
1859 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_U,
1860 finderArgs, list);
1861 }
1862 else {
1863 user = list.get(0);
1864
1865 cacheResult(user);
1866
1867 if ((user.getCompanyId() != companyId) ||
1868 (user.getUserId() != userId)) {
1869 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_U,
1870 finderArgs, user);
1871 }
1872 }
1873
1874 return user;
1875 }
1876 catch (Exception e) {
1877 throw processException(e);
1878 }
1879 finally {
1880 if (result == null) {
1881 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_U,
1882 finderArgs, new ArrayList<User>());
1883 }
1884
1885 closeSession(session);
1886 }
1887 }
1888 else {
1889 if (result instanceof List<?>) {
1890 return null;
1891 }
1892 else {
1893 return (User)result;
1894 }
1895 }
1896 }
1897
1898 public User findByC_DU(long companyId, boolean defaultUser)
1899 throws NoSuchUserException, SystemException {
1900 User user = fetchByC_DU(companyId, defaultUser);
1901
1902 if (user == null) {
1903 StringBuilder msg = new StringBuilder();
1904
1905 msg.append("No User exists with the key {");
1906
1907 msg.append("companyId=" + companyId);
1908
1909 msg.append(", ");
1910 msg.append("defaultUser=" + defaultUser);
1911
1912 msg.append(StringPool.CLOSE_CURLY_BRACE);
1913
1914 if (_log.isWarnEnabled()) {
1915 _log.warn(msg.toString());
1916 }
1917
1918 throw new NoSuchUserException(msg.toString());
1919 }
1920
1921 return user;
1922 }
1923
1924 public User fetchByC_DU(long companyId, boolean defaultUser)
1925 throws SystemException {
1926 return fetchByC_DU(companyId, defaultUser, true);
1927 }
1928
1929 public User fetchByC_DU(long companyId, boolean defaultUser,
1930 boolean retrieveFromCache) throws SystemException {
1931 Object[] finderArgs = new Object[] {
1932 new Long(companyId), Boolean.valueOf(defaultUser)
1933 };
1934
1935 Object result = null;
1936
1937 if (retrieveFromCache) {
1938 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_DU,
1939 finderArgs, this);
1940 }
1941
1942 if (result == null) {
1943 Session session = null;
1944
1945 try {
1946 session = openSession();
1947
1948 StringBuilder query = new StringBuilder();
1949
1950 query.append("SELECT user FROM User user WHERE ");
1951
1952 query.append("user.companyId = ?");
1953
1954 query.append(" AND ");
1955
1956 query.append("user.defaultUser = ?");
1957
1958 query.append(" ");
1959
1960 Query q = session.createQuery(query.toString());
1961
1962 QueryPos qPos = QueryPos.getInstance(q);
1963
1964 qPos.add(companyId);
1965
1966 qPos.add(defaultUser);
1967
1968 List<User> list = q.list();
1969
1970 result = list;
1971
1972 User user = null;
1973
1974 if (list.isEmpty()) {
1975 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_DU,
1976 finderArgs, list);
1977 }
1978 else {
1979 user = list.get(0);
1980
1981 cacheResult(user);
1982
1983 if ((user.getCompanyId() != companyId) ||
1984 (user.getDefaultUser() != defaultUser)) {
1985 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_DU,
1986 finderArgs, user);
1987 }
1988 }
1989
1990 return user;
1991 }
1992 catch (Exception e) {
1993 throw processException(e);
1994 }
1995 finally {
1996 if (result == null) {
1997 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_DU,
1998 finderArgs, new ArrayList<User>());
1999 }
2000
2001 closeSession(session);
2002 }
2003 }
2004 else {
2005 if (result instanceof List<?>) {
2006 return null;
2007 }
2008 else {
2009 return (User)result;
2010 }
2011 }
2012 }
2013
2014 public User findByC_SN(long companyId, String screenName)
2015 throws NoSuchUserException, SystemException {
2016 User user = fetchByC_SN(companyId, screenName);
2017
2018 if (user == null) {
2019 StringBuilder msg = new StringBuilder();
2020
2021 msg.append("No User exists with the key {");
2022
2023 msg.append("companyId=" + companyId);
2024
2025 msg.append(", ");
2026 msg.append("screenName=" + screenName);
2027
2028 msg.append(StringPool.CLOSE_CURLY_BRACE);
2029
2030 if (_log.isWarnEnabled()) {
2031 _log.warn(msg.toString());
2032 }
2033
2034 throw new NoSuchUserException(msg.toString());
2035 }
2036
2037 return user;
2038 }
2039
2040 public User fetchByC_SN(long companyId, String screenName)
2041 throws SystemException {
2042 return fetchByC_SN(companyId, screenName, true);
2043 }
2044
2045 public User fetchByC_SN(long companyId, String screenName,
2046 boolean retrieveFromCache) throws SystemException {
2047 Object[] finderArgs = new Object[] { new Long(companyId), screenName };
2048
2049 Object result = null;
2050
2051 if (retrieveFromCache) {
2052 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_SN,
2053 finderArgs, this);
2054 }
2055
2056 if (result == null) {
2057 Session session = null;
2058
2059 try {
2060 session = openSession();
2061
2062 StringBuilder query = new StringBuilder();
2063
2064 query.append("SELECT user FROM User user WHERE ");
2065
2066 query.append("user.companyId = ?");
2067
2068 query.append(" AND ");
2069
2070 if (screenName == null) {
2071 query.append("user.screenName IS NULL");
2072 }
2073 else {
2074 query.append("user.screenName = ?");
2075 }
2076
2077 query.append(" ");
2078
2079 Query q = session.createQuery(query.toString());
2080
2081 QueryPos qPos = QueryPos.getInstance(q);
2082
2083 qPos.add(companyId);
2084
2085 if (screenName != null) {
2086 qPos.add(screenName);
2087 }
2088
2089 List<User> list = q.list();
2090
2091 result = list;
2092
2093 User user = null;
2094
2095 if (list.isEmpty()) {
2096 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_SN,
2097 finderArgs, list);
2098 }
2099 else {
2100 user = list.get(0);
2101
2102 cacheResult(user);
2103
2104 if ((user.getCompanyId() != companyId) ||
2105 (user.getScreenName() == null) ||
2106 !user.getScreenName().equals(screenName)) {
2107 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_SN,
2108 finderArgs, user);
2109 }
2110 }
2111
2112 return user;
2113 }
2114 catch (Exception e) {
2115 throw processException(e);
2116 }
2117 finally {
2118 if (result == null) {
2119 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_SN,
2120 finderArgs, new ArrayList<User>());
2121 }
2122
2123 closeSession(session);
2124 }
2125 }
2126 else {
2127 if (result instanceof List<?>) {
2128 return null;
2129 }
2130 else {
2131 return (User)result;
2132 }
2133 }
2134 }
2135
2136 public User findByC_EA(long companyId, String emailAddress)
2137 throws NoSuchUserException, SystemException {
2138 User user = fetchByC_EA(companyId, emailAddress);
2139
2140 if (user == null) {
2141 StringBuilder msg = new StringBuilder();
2142
2143 msg.append("No User exists with the key {");
2144
2145 msg.append("companyId=" + companyId);
2146
2147 msg.append(", ");
2148 msg.append("emailAddress=" + emailAddress);
2149
2150 msg.append(StringPool.CLOSE_CURLY_BRACE);
2151
2152 if (_log.isWarnEnabled()) {
2153 _log.warn(msg.toString());
2154 }
2155
2156 throw new NoSuchUserException(msg.toString());
2157 }
2158
2159 return user;
2160 }
2161
2162 public User fetchByC_EA(long companyId, String emailAddress)
2163 throws SystemException {
2164 return fetchByC_EA(companyId, emailAddress, true);
2165 }
2166
2167 public User fetchByC_EA(long companyId, String emailAddress,
2168 boolean retrieveFromCache) throws SystemException {
2169 Object[] finderArgs = new Object[] { new Long(companyId), emailAddress };
2170
2171 Object result = null;
2172
2173 if (retrieveFromCache) {
2174 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_EA,
2175 finderArgs, this);
2176 }
2177
2178 if (result == null) {
2179 Session session = null;
2180
2181 try {
2182 session = openSession();
2183
2184 StringBuilder query = new StringBuilder();
2185
2186 query.append("SELECT user FROM User user WHERE ");
2187
2188 query.append("user.companyId = ?");
2189
2190 query.append(" AND ");
2191
2192 if (emailAddress == null) {
2193 query.append("user.emailAddress IS NULL");
2194 }
2195 else {
2196 query.append("user.emailAddress = ?");
2197 }
2198
2199 query.append(" ");
2200
2201 Query q = session.createQuery(query.toString());
2202
2203 QueryPos qPos = QueryPos.getInstance(q);
2204
2205 qPos.add(companyId);
2206
2207 if (emailAddress != null) {
2208 qPos.add(emailAddress);
2209 }
2210
2211 List<User> list = q.list();
2212
2213 result = list;
2214
2215 User user = null;
2216
2217 if (list.isEmpty()) {
2218 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_EA,
2219 finderArgs, list);
2220 }
2221 else {
2222 user = list.get(0);
2223
2224 cacheResult(user);
2225
2226 if ((user.getCompanyId() != companyId) ||
2227 (user.getEmailAddress() == null) ||
2228 !user.getEmailAddress().equals(emailAddress)) {
2229 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_EA,
2230 finderArgs, user);
2231 }
2232 }
2233
2234 return user;
2235 }
2236 catch (Exception e) {
2237 throw processException(e);
2238 }
2239 finally {
2240 if (result == null) {
2241 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_EA,
2242 finderArgs, new ArrayList<User>());
2243 }
2244
2245 closeSession(session);
2246 }
2247 }
2248 else {
2249 if (result instanceof List<?>) {
2250 return null;
2251 }
2252 else {
2253 return (User)result;
2254 }
2255 }
2256 }
2257
2258 public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery)
2259 throws SystemException {
2260 Session session = null;
2261
2262 try {
2263 session = openSession();
2264
2265 dynamicQuery.compile(session);
2266
2267 return dynamicQuery.list();
2268 }
2269 catch (Exception e) {
2270 throw processException(e);
2271 }
2272 finally {
2273 closeSession(session);
2274 }
2275 }
2276
2277 public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery,
2278 int start, int end) throws SystemException {
2279 Session session = null;
2280
2281 try {
2282 session = openSession();
2283
2284 dynamicQuery.setLimit(start, end);
2285
2286 dynamicQuery.compile(session);
2287
2288 return dynamicQuery.list();
2289 }
2290 catch (Exception e) {
2291 throw processException(e);
2292 }
2293 finally {
2294 closeSession(session);
2295 }
2296 }
2297
2298 public List<User> findAll() throws SystemException {
2299 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2300 }
2301
2302 public List<User> findAll(int start, int end) throws SystemException {
2303 return findAll(start, end, null);
2304 }
2305
2306 public List<User> findAll(int start, int end, OrderByComparator obc)
2307 throws SystemException {
2308 Object[] finderArgs = new Object[] {
2309 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
2310 };
2311
2312 List<User> list = (List<User>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
2313 finderArgs, this);
2314
2315 if (list == null) {
2316 Session session = null;
2317
2318 try {
2319 session = openSession();
2320
2321 StringBuilder query = new StringBuilder();
2322
2323 query.append("SELECT user FROM User user ");
2324
2325 if (obc != null) {
2326 query.append("ORDER BY ");
2327
2328 String[] orderByFields = obc.getOrderByFields();
2329
2330 for (int i = 0; i < orderByFields.length; i++) {
2331 query.append("user.");
2332 query.append(orderByFields[i]);
2333
2334 if (obc.isAscending()) {
2335 query.append(" ASC");
2336 }
2337 else {
2338 query.append(" DESC");
2339 }
2340
2341 if ((i + 1) < orderByFields.length) {
2342 query.append(", ");
2343 }
2344 }
2345 }
2346
2347 Query q = session.createQuery(query.toString());
2348
2349 if (obc == null) {
2350 list = (List<User>)QueryUtil.list(q, getDialect(), start,
2351 end, false);
2352
2353 Collections.sort(list);
2354 }
2355 else {
2356 list = (List<User>)QueryUtil.list(q, getDialect(), start,
2357 end);
2358 }
2359 }
2360 catch (Exception e) {
2361 throw processException(e);
2362 }
2363 finally {
2364 if (list == null) {
2365 list = new ArrayList<User>();
2366 }
2367
2368 cacheResult(list);
2369
2370 FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
2371
2372 closeSession(session);
2373 }
2374 }
2375
2376 return list;
2377 }
2378
2379 public void removeByUuid(String uuid) throws SystemException {
2380 for (User user : findByUuid(uuid)) {
2381 remove(user);
2382 }
2383 }
2384
2385 public void removeByCompanyId(long companyId) throws SystemException {
2386 for (User user : findByCompanyId(companyId)) {
2387 remove(user);
2388 }
2389 }
2390
2391 public void removeByContactId(long contactId)
2392 throws NoSuchUserException, SystemException {
2393 User user = findByContactId(contactId);
2394
2395 remove(user);
2396 }
2397
2398 public void removeByEmailAddress(String emailAddress)
2399 throws SystemException {
2400 for (User user : findByEmailAddress(emailAddress)) {
2401 remove(user);
2402 }
2403 }
2404
2405 public void removeByOpenId(String openId)
2406 throws NoSuchUserException, SystemException {
2407 User user = findByOpenId(openId);
2408
2409 remove(user);
2410 }
2411
2412 public void removeByPortraitId(long portraitId)
2413 throws NoSuchUserException, SystemException {
2414 User user = findByPortraitId(portraitId);
2415
2416 remove(user);
2417 }
2418
2419 public void removeByC_U(long companyId, long userId)
2420 throws NoSuchUserException, SystemException {
2421 User user = findByC_U(companyId, userId);
2422
2423 remove(user);
2424 }
2425
2426 public void removeByC_DU(long companyId, boolean defaultUser)
2427 throws NoSuchUserException, SystemException {
2428 User user = findByC_DU(companyId, defaultUser);
2429
2430 remove(user);
2431 }
2432
2433 public void removeByC_SN(long companyId, String screenName)
2434 throws NoSuchUserException, SystemException {
2435 User user = findByC_SN(companyId, screenName);
2436
2437 remove(user);
2438 }
2439
2440 public void removeByC_EA(long companyId, String emailAddress)
2441 throws NoSuchUserException, SystemException {
2442 User user = findByC_EA(companyId, emailAddress);
2443
2444 remove(user);
2445 }
2446
2447 public void removeAll() throws SystemException {
2448 for (User user : findAll()) {
2449 remove(user);
2450 }
2451 }
2452
2453 public int countByUuid(String uuid) throws SystemException {
2454 Object[] finderArgs = new Object[] { uuid };
2455
2456 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID,
2457 finderArgs, this);
2458
2459 if (count == null) {
2460 Session session = null;
2461
2462 try {
2463 session = openSession();
2464
2465 StringBuilder query = new StringBuilder();
2466
2467 query.append("SELECT COUNT(user) ");
2468 query.append("FROM User user WHERE ");
2469
2470 if (uuid == null) {
2471 query.append("user.uuid IS NULL");
2472 }
2473 else {
2474 query.append("user.uuid = ?");
2475 }
2476
2477 query.append(" ");
2478
2479 Query q = session.createQuery(query.toString());
2480
2481 QueryPos qPos = QueryPos.getInstance(q);
2482
2483 if (uuid != null) {
2484 qPos.add(uuid);
2485 }
2486
2487 count = (Long)q.uniqueResult();
2488 }
2489 catch (Exception e) {
2490 throw processException(e);
2491 }
2492 finally {
2493 if (count == null) {
2494 count = Long.valueOf(0);
2495 }
2496
2497 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID,
2498 finderArgs, count);
2499
2500 closeSession(session);
2501 }
2502 }
2503
2504 return count.intValue();
2505 }
2506
2507 public int countByCompanyId(long companyId) throws SystemException {
2508 Object[] finderArgs = new Object[] { new Long(companyId) };
2509
2510 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_COMPANYID,
2511 finderArgs, this);
2512
2513 if (count == null) {
2514 Session session = null;
2515
2516 try {
2517 session = openSession();
2518
2519 StringBuilder query = new StringBuilder();
2520
2521 query.append("SELECT COUNT(user) ");
2522 query.append("FROM User user WHERE ");
2523
2524 query.append("user.companyId = ?");
2525
2526 query.append(" ");
2527
2528 Query q = session.createQuery(query.toString());
2529
2530 QueryPos qPos = QueryPos.getInstance(q);
2531
2532 qPos.add(companyId);
2533
2534 count = (Long)q.uniqueResult();
2535 }
2536 catch (Exception e) {
2537 throw processException(e);
2538 }
2539 finally {
2540 if (count == null) {
2541 count = Long.valueOf(0);
2542 }
2543
2544 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_COMPANYID,
2545 finderArgs, count);
2546
2547 closeSession(session);
2548 }
2549 }
2550
2551 return count.intValue();
2552 }
2553
2554 public int countByContactId(long contactId) throws SystemException {
2555 Object[] finderArgs = new Object[] { new Long(contactId) };
2556
2557 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_CONTACTID,
2558 finderArgs, this);
2559
2560 if (count == null) {
2561 Session session = null;
2562
2563 try {
2564 session = openSession();
2565
2566 StringBuilder query = new StringBuilder();
2567
2568 query.append("SELECT COUNT(user) ");
2569 query.append("FROM User user WHERE ");
2570
2571 query.append("user.contactId = ?");
2572
2573 query.append(" ");
2574
2575 Query q = session.createQuery(query.toString());
2576
2577 QueryPos qPos = QueryPos.getInstance(q);
2578
2579 qPos.add(contactId);
2580
2581 count = (Long)q.uniqueResult();
2582 }
2583 catch (Exception e) {
2584 throw processException(e);
2585 }
2586 finally {
2587 if (count == null) {
2588 count = Long.valueOf(0);
2589 }
2590
2591 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_CONTACTID,
2592 finderArgs, count);
2593
2594 closeSession(session);
2595 }
2596 }
2597
2598 return count.intValue();
2599 }
2600
2601 public int countByEmailAddress(String emailAddress)
2602 throws SystemException {
2603 Object[] finderArgs = new Object[] { emailAddress };
2604
2605 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_EMAILADDRESS,
2606 finderArgs, this);
2607
2608 if (count == null) {
2609 Session session = null;
2610
2611 try {
2612 session = openSession();
2613
2614 StringBuilder query = new StringBuilder();
2615
2616 query.append("SELECT COUNT(user) ");
2617 query.append("FROM User user WHERE ");
2618
2619 if (emailAddress == null) {
2620 query.append("user.emailAddress IS NULL");
2621 }
2622 else {
2623 query.append("user.emailAddress = ?");
2624 }
2625
2626 query.append(" ");
2627
2628 Query q = session.createQuery(query.toString());
2629
2630 QueryPos qPos = QueryPos.getInstance(q);
2631
2632 if (emailAddress != null) {
2633 qPos.add(emailAddress);
2634 }
2635
2636 count = (Long)q.uniqueResult();
2637 }
2638 catch (Exception e) {
2639 throw processException(e);
2640 }
2641 finally {
2642 if (count == null) {
2643 count = Long.valueOf(0);
2644 }
2645
2646 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_EMAILADDRESS,
2647 finderArgs, count);
2648
2649 closeSession(session);
2650 }
2651 }
2652
2653 return count.intValue();
2654 }
2655
2656 public int countByOpenId(String openId) throws SystemException {
2657 Object[] finderArgs = new Object[] { openId };
2658
2659 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_OPENID,
2660 finderArgs, this);
2661
2662 if (count == null) {
2663 Session session = null;
2664
2665 try {
2666 session = openSession();
2667
2668 StringBuilder query = new StringBuilder();
2669
2670 query.append("SELECT COUNT(user) ");
2671 query.append("FROM User user WHERE ");
2672
2673 if (openId == null) {
2674 query.append("user.openId IS NULL");
2675 }
2676 else {
2677 query.append("user.openId = ?");
2678 }
2679
2680 query.append(" ");
2681
2682 Query q = session.createQuery(query.toString());
2683
2684 QueryPos qPos = QueryPos.getInstance(q);
2685
2686 if (openId != null) {
2687 qPos.add(openId);
2688 }
2689
2690 count = (Long)q.uniqueResult();
2691 }
2692 catch (Exception e) {
2693 throw processException(e);
2694 }
2695 finally {
2696 if (count == null) {
2697 count = Long.valueOf(0);
2698 }
2699
2700 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_OPENID,
2701 finderArgs, count);
2702
2703 closeSession(session);
2704 }
2705 }
2706
2707 return count.intValue();
2708 }
2709
2710 public int countByPortraitId(long portraitId) throws SystemException {
2711 Object[] finderArgs = new Object[] { new Long(portraitId) };
2712
2713 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_PORTRAITID,
2714 finderArgs, this);
2715
2716 if (count == null) {
2717 Session session = null;
2718
2719 try {
2720 session = openSession();
2721
2722 StringBuilder query = new StringBuilder();
2723
2724 query.append("SELECT COUNT(user) ");
2725 query.append("FROM User user WHERE ");
2726
2727 query.append("user.portraitId = ?");
2728
2729 query.append(" ");
2730
2731 Query q = session.createQuery(query.toString());
2732
2733 QueryPos qPos = QueryPos.getInstance(q);
2734
2735 qPos.add(portraitId);
2736
2737 count = (Long)q.uniqueResult();
2738 }
2739 catch (Exception e) {
2740 throw processException(e);
2741 }
2742 finally {
2743 if (count == null) {
2744 count = Long.valueOf(0);
2745 }
2746
2747 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_PORTRAITID,
2748 finderArgs, count);
2749
2750 closeSession(session);
2751 }
2752 }
2753
2754 return count.intValue();
2755 }
2756
2757 public int countByC_U(long companyId, long userId)
2758 throws SystemException {
2759 Object[] finderArgs = new Object[] { new Long(companyId), new Long(userId) };
2760
2761 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_U,
2762 finderArgs, this);
2763
2764 if (count == null) {
2765 Session session = null;
2766
2767 try {
2768 session = openSession();
2769
2770 StringBuilder query = new StringBuilder();
2771
2772 query.append("SELECT COUNT(user) ");
2773 query.append("FROM User user WHERE ");
2774
2775 query.append("user.companyId = ?");
2776
2777 query.append(" AND ");
2778
2779 query.append("user.userId = ?");
2780
2781 query.append(" ");
2782
2783 Query q = session.createQuery(query.toString());
2784
2785 QueryPos qPos = QueryPos.getInstance(q);
2786
2787 qPos.add(companyId);
2788
2789 qPos.add(userId);
2790
2791 count = (Long)q.uniqueResult();
2792 }
2793 catch (Exception e) {
2794 throw processException(e);
2795 }
2796 finally {
2797 if (count == null) {
2798 count = Long.valueOf(0);
2799 }
2800
2801 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_U, finderArgs,
2802 count);
2803
2804 closeSession(session);
2805 }
2806 }
2807
2808 return count.intValue();
2809 }
2810
2811 public int countByC_DU(long companyId, boolean defaultUser)
2812 throws SystemException {
2813 Object[] finderArgs = new Object[] {
2814 new Long(companyId), Boolean.valueOf(defaultUser)
2815 };
2816
2817 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_DU,
2818 finderArgs, this);
2819
2820 if (count == null) {
2821 Session session = null;
2822
2823 try {
2824 session = openSession();
2825
2826 StringBuilder query = new StringBuilder();
2827
2828 query.append("SELECT COUNT(user) ");
2829 query.append("FROM User user WHERE ");
2830
2831 query.append("user.companyId = ?");
2832
2833 query.append(" AND ");
2834
2835 query.append("user.defaultUser = ?");
2836
2837 query.append(" ");
2838
2839 Query q = session.createQuery(query.toString());
2840
2841 QueryPos qPos = QueryPos.getInstance(q);
2842
2843 qPos.add(companyId);
2844
2845 qPos.add(defaultUser);
2846
2847 count = (Long)q.uniqueResult();
2848 }
2849 catch (Exception e) {
2850 throw processException(e);
2851 }
2852 finally {
2853 if (count == null) {
2854 count = Long.valueOf(0);
2855 }
2856
2857 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_DU,
2858 finderArgs, count);
2859
2860 closeSession(session);
2861 }
2862 }
2863
2864 return count.intValue();
2865 }
2866
2867 public int countByC_SN(long companyId, String screenName)
2868 throws SystemException {
2869 Object[] finderArgs = new Object[] { new Long(companyId), screenName };
2870
2871 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_SN,
2872 finderArgs, this);
2873
2874 if (count == null) {
2875 Session session = null;
2876
2877 try {
2878 session = openSession();
2879
2880 StringBuilder query = new StringBuilder();
2881
2882 query.append("SELECT COUNT(user) ");
2883 query.append("FROM User user WHERE ");
2884
2885 query.append("user.companyId = ?");
2886
2887 query.append(" AND ");
2888
2889 if (screenName == null) {
2890 query.append("user.screenName IS NULL");
2891 }
2892 else {
2893 query.append("user.screenName = ?");
2894 }
2895
2896 query.append(" ");
2897
2898 Query q = session.createQuery(query.toString());
2899
2900 QueryPos qPos = QueryPos.getInstance(q);
2901
2902 qPos.add(companyId);
2903
2904 if (screenName != null) {
2905 qPos.add(screenName);
2906 }
2907
2908 count = (Long)q.uniqueResult();
2909 }
2910 catch (Exception e) {
2911 throw processException(e);
2912 }
2913 finally {
2914 if (count == null) {
2915 count = Long.valueOf(0);
2916 }
2917
2918 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_SN,
2919 finderArgs, count);
2920
2921 closeSession(session);
2922 }
2923 }
2924
2925 return count.intValue();
2926 }
2927
2928 public int countByC_EA(long companyId, String emailAddress)
2929 throws SystemException {
2930 Object[] finderArgs = new Object[] { new Long(companyId), emailAddress };
2931
2932 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_EA,
2933 finderArgs, this);
2934
2935 if (count == null) {
2936 Session session = null;
2937
2938 try {
2939 session = openSession();
2940
2941 StringBuilder query = new StringBuilder();
2942
2943 query.append("SELECT COUNT(user) ");
2944 query.append("FROM User user WHERE ");
2945
2946 query.append("user.companyId = ?");
2947
2948 query.append(" AND ");
2949
2950 if (emailAddress == null) {
2951 query.append("user.emailAddress IS NULL");
2952 }
2953 else {
2954 query.append("user.emailAddress = ?");
2955 }
2956
2957 query.append(" ");
2958
2959 Query q = session.createQuery(query.toString());
2960
2961 QueryPos qPos = QueryPos.getInstance(q);
2962
2963 qPos.add(companyId);
2964
2965 if (emailAddress != null) {
2966 qPos.add(emailAddress);
2967 }
2968
2969 count = (Long)q.uniqueResult();
2970 }
2971 catch (Exception e) {
2972 throw processException(e);
2973 }
2974 finally {
2975 if (count == null) {
2976 count = Long.valueOf(0);
2977 }
2978
2979 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_EA,
2980 finderArgs, count);
2981
2982 closeSession(session);
2983 }
2984 }
2985
2986 return count.intValue();
2987 }
2988
2989 public int countAll() throws SystemException {
2990 Object[] finderArgs = new Object[0];
2991
2992 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
2993 finderArgs, this);
2994
2995 if (count == null) {
2996 Session session = null;
2997
2998 try {
2999 session = openSession();
3000
3001 Query q = session.createQuery(
3002 "SELECT COUNT(user) FROM User user");
3003
3004 count = (Long)q.uniqueResult();
3005 }
3006 catch (Exception e) {
3007 throw processException(e);
3008 }
3009 finally {
3010 if (count == null) {
3011 count = Long.valueOf(0);
3012 }
3013
3014 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
3015 count);
3016
3017 closeSession(session);
3018 }
3019 }
3020
3021 return count.intValue();
3022 }
3023
3024 public List<com.liferay.portal.model.Group> getGroups(long pk)
3025 throws SystemException {
3026 return getGroups(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
3027 }
3028
3029 public List<com.liferay.portal.model.Group> getGroups(long pk, int start,
3030 int end) throws SystemException {
3031 return getGroups(pk, start, end, null);
3032 }
3033
3034 public static final FinderPath FINDER_PATH_GET_GROUPS = new FinderPath(com.liferay.portal.model.impl.GroupModelImpl.ENTITY_CACHE_ENABLED,
3035 UserModelImpl.FINDER_CACHE_ENABLED_USERS_GROUPS, "Users_Groups",
3036 "getGroups",
3037 new String[] {
3038 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
3039 "com.liferay.portal.kernel.util.OrderByComparator"
3040 });
3041
3042 public List<com.liferay.portal.model.Group> getGroups(long pk, int start,
3043 int end, OrderByComparator obc) throws SystemException {
3044 Object[] finderArgs = new Object[] {
3045 new Long(pk), String.valueOf(start), String.valueOf(end),
3046 String.valueOf(obc)
3047 };
3048
3049 List<com.liferay.portal.model.Group> list = (List<com.liferay.portal.model.Group>)FinderCacheUtil.getResult(FINDER_PATH_GET_GROUPS,
3050 finderArgs, this);
3051
3052 if (list == null) {
3053 Session session = null;
3054
3055 try {
3056 session = openSession();
3057
3058 StringBuilder sb = new StringBuilder();
3059
3060 sb.append(_SQL_GETGROUPS);
3061
3062 if (obc != null) {
3063 sb.append("ORDER BY ");
3064 sb.append(obc.getOrderBy());
3065 }
3066
3067 else {
3068 sb.append("ORDER BY ");
3069
3070 sb.append("Group_.name ASC");
3071 }
3072
3073 String sql = sb.toString();
3074
3075 SQLQuery q = session.createSQLQuery(sql);
3076
3077 q.addEntity("Group_",
3078 com.liferay.portal.model.impl.GroupImpl.class);
3079
3080 QueryPos qPos = QueryPos.getInstance(q);
3081
3082 qPos.add(pk);
3083
3084 list = (List<com.liferay.portal.model.Group>)QueryUtil.list(q,
3085 getDialect(), start, end);
3086 }
3087 catch (Exception e) {
3088 throw processException(e);
3089 }
3090 finally {
3091 if (list == null) {
3092 list = new ArrayList<com.liferay.portal.model.Group>();
3093 }
3094
3095 groupPersistence.cacheResult(list);
3096
3097 FinderCacheUtil.putResult(FINDER_PATH_GET_GROUPS, finderArgs,
3098 list);
3099
3100 closeSession(session);
3101 }
3102 }
3103
3104 return list;
3105 }
3106
3107 public static final FinderPath FINDER_PATH_GET_GROUPS_SIZE = new FinderPath(com.liferay.portal.model.impl.GroupModelImpl.ENTITY_CACHE_ENABLED,
3108 UserModelImpl.FINDER_CACHE_ENABLED_USERS_GROUPS, "Users_Groups",
3109 "getGroupsSize", new String[] { Long.class.getName() });
3110
3111 public int getGroupsSize(long pk) throws SystemException {
3112 Object[] finderArgs = new Object[] { new Long(pk) };
3113
3114 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_GROUPS_SIZE,
3115 finderArgs, this);
3116
3117 if (count == null) {
3118 Session session = null;
3119
3120 try {
3121 session = openSession();
3122
3123 SQLQuery q = session.createSQLQuery(_SQL_GETGROUPSSIZE);
3124
3125 q.addScalar(COUNT_COLUMN_NAME, Type.LONG);
3126
3127 QueryPos qPos = QueryPos.getInstance(q);
3128
3129 qPos.add(pk);
3130
3131 count = (Long)q.uniqueResult();
3132 }
3133 catch (Exception e) {
3134 throw processException(e);
3135 }
3136 finally {
3137 if (count == null) {
3138 count = Long.valueOf(0);
3139 }
3140
3141 FinderCacheUtil.putResult(FINDER_PATH_GET_GROUPS_SIZE,
3142 finderArgs, count);
3143
3144 closeSession(session);
3145 }
3146 }
3147
3148 return count.intValue();
3149 }
3150
3151 public static final FinderPath FINDER_PATH_CONTAINS_GROUP = new FinderPath(com.liferay.portal.model.impl.GroupModelImpl.ENTITY_CACHE_ENABLED,
3152 UserModelImpl.FINDER_CACHE_ENABLED_USERS_GROUPS, "Users_Groups",
3153 "containsGroup",
3154 new String[] { Long.class.getName(), Long.class.getName() });
3155
3156 public boolean containsGroup(long pk, long groupPK)
3157 throws SystemException {
3158 Object[] finderArgs = new Object[] { new Long(pk), new Long(groupPK) };
3159
3160 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_GROUP,
3161 finderArgs, this);
3162
3163 if (value == null) {
3164 try {
3165 value = Boolean.valueOf(containsGroup.contains(pk, groupPK));
3166 }
3167 catch (Exception e) {
3168 throw processException(e);
3169 }
3170 finally {
3171 if (value == null) {
3172 value = Boolean.FALSE;
3173 }
3174
3175 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_GROUP,
3176 finderArgs, value);
3177 }
3178 }
3179
3180 return value.booleanValue();
3181 }
3182
3183 public boolean containsGroups(long pk) throws SystemException {
3184 if (getGroupsSize(pk) > 0) {
3185 return true;
3186 }
3187 else {
3188 return false;
3189 }
3190 }
3191
3192 public void addGroup(long pk, long groupPK) throws SystemException {
3193 try {
3194 addGroup.add(pk, groupPK);
3195 }
3196 catch (Exception e) {
3197 throw processException(e);
3198 }
3199 finally {
3200 FinderCacheUtil.clearCache("Users_Groups");
3201 }
3202 }
3203
3204 public void addGroup(long pk, com.liferay.portal.model.Group group)
3205 throws SystemException {
3206 try {
3207 addGroup.add(pk, group.getPrimaryKey());
3208 }
3209 catch (Exception e) {
3210 throw processException(e);
3211 }
3212 finally {
3213 FinderCacheUtil.clearCache("Users_Groups");
3214 }
3215 }
3216
3217 public void addGroups(long pk, long[] groupPKs) throws SystemException {
3218 try {
3219 for (long groupPK : groupPKs) {
3220 addGroup.add(pk, groupPK);
3221 }
3222 }
3223 catch (Exception e) {
3224 throw processException(e);
3225 }
3226 finally {
3227 FinderCacheUtil.clearCache("Users_Groups");
3228 }
3229 }
3230
3231 public void addGroups(long pk, List<com.liferay.portal.model.Group> groups)
3232 throws SystemException {
3233 try {
3234 for (com.liferay.portal.model.Group group : groups) {
3235 addGroup.add(pk, group.getPrimaryKey());
3236 }
3237 }
3238 catch (Exception e) {
3239 throw processException(e);
3240 }
3241 finally {
3242 FinderCacheUtil.clearCache("Users_Groups");
3243 }
3244 }
3245
3246 public void clearGroups(long pk) throws SystemException {
3247 try {
3248 clearGroups.clear(pk);
3249 }
3250 catch (Exception e) {
3251 throw processException(e);
3252 }
3253 finally {
3254 FinderCacheUtil.clearCache("Users_Groups");
3255 }
3256 }
3257
3258 public void removeGroup(long pk, long groupPK) throws SystemException {
3259 try {
3260 removeGroup.remove(pk, groupPK);
3261 }
3262 catch (Exception e) {
3263 throw processException(e);
3264 }
3265 finally {
3266 FinderCacheUtil.clearCache("Users_Groups");
3267 }
3268 }
3269
3270 public void removeGroup(long pk, com.liferay.portal.model.Group group)
3271 throws SystemException {
3272 try {
3273 removeGroup.remove(pk, group.getPrimaryKey());
3274 }
3275 catch (Exception e) {
3276 throw processException(e);
3277 }
3278 finally {
3279 FinderCacheUtil.clearCache("Users_Groups");
3280 }
3281 }
3282
3283 public void removeGroups(long pk, long[] groupPKs)
3284 throws SystemException {
3285 try {
3286 for (long groupPK : groupPKs) {
3287 removeGroup.remove(pk, groupPK);
3288 }
3289 }
3290 catch (Exception e) {
3291 throw processException(e);
3292 }
3293 finally {
3294 FinderCacheUtil.clearCache("Users_Groups");
3295 }
3296 }
3297
3298 public void removeGroups(long pk,
3299 List<com.liferay.portal.model.Group> groups) throws SystemException {
3300 try {
3301 for (com.liferay.portal.model.Group group : groups) {
3302 removeGroup.remove(pk, group.getPrimaryKey());
3303 }
3304 }
3305 catch (Exception e) {
3306 throw processException(e);
3307 }
3308 finally {
3309 FinderCacheUtil.clearCache("Users_Groups");
3310 }
3311 }
3312
3313 public void setGroups(long pk, long[] groupPKs) throws SystemException {
3314 try {
3315 Set<Long> groupPKSet = SetUtil.fromArray(groupPKs);
3316
3317 List<com.liferay.portal.model.Group> groups = getGroups(pk);
3318
3319 for (com.liferay.portal.model.Group group : groups) {
3320 if (!groupPKSet.contains(group.getPrimaryKey())) {
3321 removeGroup.remove(pk, group.getPrimaryKey());
3322 }
3323 else {
3324 groupPKSet.remove(group.getPrimaryKey());
3325 }
3326 }
3327
3328 for (Long groupPK : groupPKSet) {
3329 addGroup.add(pk, groupPK);
3330 }
3331 }
3332 catch (Exception e) {
3333 throw processException(e);
3334 }
3335 finally {
3336 FinderCacheUtil.clearCache("Users_Groups");
3337 }
3338 }
3339
3340 public void setGroups(long pk, List<com.liferay.portal.model.Group> groups)
3341 throws SystemException {
3342 try {
3343 long[] groupPKs = new long[groups.size()];
3344
3345 for (int i = 0; i < groups.size(); i++) {
3346 com.liferay.portal.model.Group group = groups.get(i);
3347
3348 groupPKs[i] = group.getPrimaryKey();
3349 }
3350
3351 setGroups(pk, groupPKs);
3352 }
3353 catch (Exception e) {
3354 throw processException(e);
3355 }
3356 finally {
3357 FinderCacheUtil.clearCache("Users_Groups");
3358 }
3359 }
3360
3361 public List<com.liferay.portal.model.Organization> getOrganizations(long pk)
3362 throws SystemException {
3363 return getOrganizations(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
3364 }
3365
3366 public List<com.liferay.portal.model.Organization> getOrganizations(
3367 long pk, int start, int end) throws SystemException {
3368 return getOrganizations(pk, start, end, null);
3369 }
3370
3371 public static final FinderPath FINDER_PATH_GET_ORGANIZATIONS = new FinderPath(com.liferay.portal.model.impl.OrganizationModelImpl.ENTITY_CACHE_ENABLED,
3372 UserModelImpl.FINDER_CACHE_ENABLED_USERS_ORGS, "Users_Orgs",
3373 "getOrganizations",
3374 new String[] {
3375 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
3376 "com.liferay.portal.kernel.util.OrderByComparator"
3377 });
3378
3379 public List<com.liferay.portal.model.Organization> getOrganizations(
3380 long pk, int start, int end, OrderByComparator obc)
3381 throws SystemException {
3382 Object[] finderArgs = new Object[] {
3383 new Long(pk), String.valueOf(start), String.valueOf(end),
3384 String.valueOf(obc)
3385 };
3386
3387 List<com.liferay.portal.model.Organization> list = (List<com.liferay.portal.model.Organization>)FinderCacheUtil.getResult(FINDER_PATH_GET_ORGANIZATIONS,
3388 finderArgs, this);
3389
3390 if (list == null) {
3391 Session session = null;
3392
3393 try {
3394 session = openSession();
3395
3396 StringBuilder sb = new StringBuilder();
3397
3398 sb.append(_SQL_GETORGANIZATIONS);
3399
3400 if (obc != null) {
3401 sb.append("ORDER BY ");
3402 sb.append(obc.getOrderBy());
3403 }
3404
3405 else {
3406 sb.append("ORDER BY ");
3407
3408 sb.append("Organization_.name ASC");
3409 }
3410
3411 String sql = sb.toString();
3412
3413 SQLQuery q = session.createSQLQuery(sql);
3414
3415 q.addEntity("Organization_",
3416 com.liferay.portal.model.impl.OrganizationImpl.class);
3417
3418 QueryPos qPos = QueryPos.getInstance(q);
3419
3420 qPos.add(pk);
3421
3422 list = (List<com.liferay.portal.model.Organization>)QueryUtil.list(q,
3423 getDialect(), start, end);
3424 }
3425 catch (Exception e) {
3426 throw processException(e);
3427 }
3428 finally {
3429 if (list == null) {
3430 list = new ArrayList<com.liferay.portal.model.Organization>();
3431 }
3432
3433 organizationPersistence.cacheResult(list);
3434
3435 FinderCacheUtil.putResult(FINDER_PATH_GET_ORGANIZATIONS,
3436 finderArgs, list);
3437
3438 closeSession(session);
3439 }
3440 }
3441
3442 return list;
3443 }
3444
3445 public static final FinderPath FINDER_PATH_GET_ORGANIZATIONS_SIZE = new FinderPath(com.liferay.portal.model.impl.OrganizationModelImpl.ENTITY_CACHE_ENABLED,
3446 UserModelImpl.FINDER_CACHE_ENABLED_USERS_ORGS, "Users_Orgs",
3447 "getOrganizationsSize", new String[] { Long.class.getName() });
3448
3449 public int getOrganizationsSize(long pk) throws SystemException {
3450 Object[] finderArgs = new Object[] { new Long(pk) };
3451
3452 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_ORGANIZATIONS_SIZE,
3453 finderArgs, this);
3454
3455 if (count == null) {
3456 Session session = null;
3457
3458 try {
3459 session = openSession();
3460
3461 SQLQuery q = session.createSQLQuery(_SQL_GETORGANIZATIONSSIZE);
3462
3463 q.addScalar(COUNT_COLUMN_NAME, Type.LONG);
3464
3465 QueryPos qPos = QueryPos.getInstance(q);
3466
3467 qPos.add(pk);
3468
3469 count = (Long)q.uniqueResult();
3470 }
3471 catch (Exception e) {
3472 throw processException(e);
3473 }
3474 finally {
3475 if (count == null) {
3476 count = Long.valueOf(0);
3477 }
3478
3479 FinderCacheUtil.putResult(FINDER_PATH_GET_ORGANIZATIONS_SIZE,
3480 finderArgs, count);
3481
3482 closeSession(session);
3483 }
3484 }
3485
3486 return count.intValue();
3487 }
3488
3489 public static final FinderPath FINDER_PATH_CONTAINS_ORGANIZATION = new FinderPath(com.liferay.portal.model.impl.OrganizationModelImpl.ENTITY_CACHE_ENABLED,
3490 UserModelImpl.FINDER_CACHE_ENABLED_USERS_ORGS, "Users_Orgs",
3491 "containsOrganization",
3492 new String[] { Long.class.getName(), Long.class.getName() });
3493
3494 public boolean containsOrganization(long pk, long organizationPK)
3495 throws SystemException {
3496 Object[] finderArgs = new Object[] {
3497 new Long(pk),
3498
3499 new Long(organizationPK)
3500 };
3501
3502 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_ORGANIZATION,
3503 finderArgs, this);
3504
3505 if (value == null) {
3506 try {
3507 value = Boolean.valueOf(containsOrganization.contains(pk,
3508 organizationPK));
3509 }
3510 catch (Exception e) {
3511 throw processException(e);
3512 }
3513 finally {
3514 if (value == null) {
3515 value = Boolean.FALSE;
3516 }
3517
3518 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_ORGANIZATION,
3519 finderArgs, value);
3520 }
3521 }
3522
3523 return value.booleanValue();
3524 }
3525
3526 public boolean containsOrganizations(long pk) throws SystemException {
3527 if (getOrganizationsSize(pk) > 0) {
3528 return true;
3529 }
3530 else {
3531 return false;
3532 }
3533 }
3534
3535 public void addOrganization(long pk, long organizationPK)
3536 throws SystemException {
3537 try {
3538 addOrganization.add(pk, organizationPK);
3539 }
3540 catch (Exception e) {
3541 throw processException(e);
3542 }
3543 finally {
3544 FinderCacheUtil.clearCache("Users_Orgs");
3545 }
3546 }
3547
3548 public void addOrganization(long pk,
3549 com.liferay.portal.model.Organization organization)
3550 throws SystemException {
3551 try {
3552 addOrganization.add(pk, organization.getPrimaryKey());
3553 }
3554 catch (Exception e) {
3555 throw processException(e);
3556 }
3557 finally {
3558 FinderCacheUtil.clearCache("Users_Orgs");
3559 }
3560 }
3561
3562 public void addOrganizations(long pk, long[] organizationPKs)
3563 throws SystemException {
3564 try {
3565 for (long organizationPK : organizationPKs) {
3566 addOrganization.add(pk, organizationPK);
3567 }
3568 }
3569 catch (Exception e) {
3570 throw processException(e);
3571 }
3572 finally {
3573 FinderCacheUtil.clearCache("Users_Orgs");
3574 }
3575 }
3576
3577 public void addOrganizations(long pk,
3578 List<com.liferay.portal.model.Organization> organizations)
3579 throws SystemException {
3580 try {
3581 for (com.liferay.portal.model.Organization organization : organizations) {
3582 addOrganization.add(pk, organization.getPrimaryKey());
3583 }
3584 }
3585 catch (Exception e) {
3586 throw processException(e);
3587 }
3588 finally {
3589 FinderCacheUtil.clearCache("Users_Orgs");
3590 }
3591 }
3592
3593 public void clearOrganizations(long pk) throws SystemException {
3594 try {
3595 clearOrganizations.clear(pk);
3596 }
3597 catch (Exception e) {
3598 throw processException(e);
3599 }
3600 finally {
3601 FinderCacheUtil.clearCache("Users_Orgs");
3602 }
3603 }
3604
3605 public void removeOrganization(long pk, long organizationPK)
3606 throws SystemException {
3607 try {
3608 removeOrganization.remove(pk, organizationPK);
3609 }
3610 catch (Exception e) {
3611 throw processException(e);
3612 }
3613 finally {
3614 FinderCacheUtil.clearCache("Users_Orgs");
3615 }
3616 }
3617
3618 public void removeOrganization(long pk,
3619 com.liferay.portal.model.Organization organization)
3620 throws SystemException {
3621 try {
3622 removeOrganization.remove(pk, organization.getPrimaryKey());
3623 }
3624 catch (Exception e) {
3625 throw processException(e);
3626 }
3627 finally {
3628 FinderCacheUtil.clearCache("Users_Orgs");
3629 }
3630 }
3631
3632 public void removeOrganizations(long pk, long[] organizationPKs)
3633 throws SystemException {
3634 try {
3635 for (long organizationPK : organizationPKs) {
3636 removeOrganization.remove(pk, organizationPK);
3637 }
3638 }
3639 catch (Exception e) {
3640 throw processException(e);
3641 }
3642 finally {
3643 FinderCacheUtil.clearCache("Users_Orgs");
3644 }
3645 }
3646
3647 public void removeOrganizations(long pk,
3648 List<com.liferay.portal.model.Organization> organizations)
3649 throws SystemException {
3650 try {
3651 for (com.liferay.portal.model.Organization organization : organizations) {
3652 removeOrganization.remove(pk, organization.getPrimaryKey());
3653 }
3654 }
3655 catch (Exception e) {
3656 throw processException(e);
3657 }
3658 finally {
3659 FinderCacheUtil.clearCache("Users_Orgs");
3660 }
3661 }
3662
3663 public void setOrganizations(long pk, long[] organizationPKs)
3664 throws SystemException {
3665 try {
3666 Set<Long> organizationPKSet = SetUtil.fromArray(organizationPKs);
3667
3668 List<com.liferay.portal.model.Organization> organizations = getOrganizations(pk);
3669
3670 for (com.liferay.portal.model.Organization organization : organizations) {
3671 if (!organizationPKSet.contains(organization.getPrimaryKey())) {
3672 removeOrganization.remove(pk, organization.getPrimaryKey());
3673 }
3674 else {
3675 organizationPKSet.remove(organization.getPrimaryKey());
3676 }
3677 }
3678
3679 for (Long organizationPK : organizationPKSet) {
3680 addOrganization.add(pk, organizationPK);
3681 }
3682 }
3683 catch (Exception e) {
3684 throw processException(e);
3685 }
3686 finally {
3687 FinderCacheUtil.clearCache("Users_Orgs");
3688 }
3689 }
3690
3691 public void setOrganizations(long pk,
3692 List<com.liferay.portal.model.Organization> organizations)
3693 throws SystemException {
3694 try {
3695 long[] organizationPKs = new long[organizations.size()];
3696
3697 for (int i = 0; i < organizations.size(); i++) {
3698 com.liferay.portal.model.Organization organization = organizations.get(i);
3699
3700 organizationPKs[i] = organization.getPrimaryKey();
3701 }
3702
3703 setOrganizations(pk, organizationPKs);
3704 }
3705 catch (Exception e) {
3706 throw processException(e);
3707 }
3708 finally {
3709 FinderCacheUtil.clearCache("Users_Orgs");
3710 }
3711 }
3712
3713 public List<com.liferay.portal.model.Permission> getPermissions(long pk)
3714 throws SystemException {
3715 return getPermissions(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
3716 }
3717
3718 public List<com.liferay.portal.model.Permission> getPermissions(long pk,
3719 int start, int end) throws SystemException {
3720 return getPermissions(pk, start, end, null);
3721 }
3722
3723 public static final FinderPath FINDER_PATH_GET_PERMISSIONS = new FinderPath(com.liferay.portal.model.impl.PermissionModelImpl.ENTITY_CACHE_ENABLED,
3724 UserModelImpl.FINDER_CACHE_ENABLED_USERS_PERMISSIONS,
3725 "Users_Permissions", "getPermissions",
3726 new String[] {
3727 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
3728 "com.liferay.portal.kernel.util.OrderByComparator"
3729 });
3730
3731 public List<com.liferay.portal.model.Permission> getPermissions(long pk,
3732 int start, int end, OrderByComparator obc) throws SystemException {
3733 Object[] finderArgs = new Object[] {
3734 new Long(pk), String.valueOf(start), String.valueOf(end),
3735 String.valueOf(obc)
3736 };
3737
3738 List<com.liferay.portal.model.Permission> list = (List<com.liferay.portal.model.Permission>)FinderCacheUtil.getResult(FINDER_PATH_GET_PERMISSIONS,
3739 finderArgs, this);
3740
3741 if (list == null) {
3742 Session session = null;
3743
3744 try {
3745 session = openSession();
3746
3747 StringBuilder sb = new StringBuilder();
3748
3749 sb.append(_SQL_GETPERMISSIONS);
3750
3751 if (obc != null) {
3752 sb.append("ORDER BY ");
3753 sb.append(obc.getOrderBy());
3754 }
3755
3756 String sql = sb.toString();
3757
3758 SQLQuery q = session.createSQLQuery(sql);
3759
3760 q.addEntity("Permission_",
3761 com.liferay.portal.model.impl.PermissionImpl.class);
3762
3763 QueryPos qPos = QueryPos.getInstance(q);
3764
3765 qPos.add(pk);
3766
3767 list = (List<com.liferay.portal.model.Permission>)QueryUtil.list(q,
3768 getDialect(), start, end);
3769 }
3770 catch (Exception e) {
3771 throw processException(e);
3772 }
3773 finally {
3774 if (list == null) {
3775 list = new ArrayList<com.liferay.portal.model.Permission>();
3776 }
3777
3778 permissionPersistence.cacheResult(list);
3779
3780 FinderCacheUtil.putResult(FINDER_PATH_GET_PERMISSIONS,
3781 finderArgs, list);
3782
3783 closeSession(session);
3784 }
3785 }
3786
3787 return list;
3788 }
3789
3790 public static final FinderPath FINDER_PATH_GET_PERMISSIONS_SIZE = new FinderPath(com.liferay.portal.model.impl.PermissionModelImpl.ENTITY_CACHE_ENABLED,
3791 UserModelImpl.FINDER_CACHE_ENABLED_USERS_PERMISSIONS,
3792 "Users_Permissions", "getPermissionsSize",
3793 new String[] { Long.class.getName() });
3794
3795 public int getPermissionsSize(long pk) throws SystemException {
3796 Object[] finderArgs = new Object[] { new Long(pk) };
3797
3798 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_PERMISSIONS_SIZE,
3799 finderArgs, this);
3800
3801 if (count == null) {
3802 Session session = null;
3803
3804 try {
3805 session = openSession();
3806
3807 SQLQuery q = session.createSQLQuery(_SQL_GETPERMISSIONSSIZE);
3808
3809 q.addScalar(COUNT_COLUMN_NAME, Type.LONG);
3810
3811 QueryPos qPos = QueryPos.getInstance(q);
3812
3813 qPos.add(pk);
3814
3815 count = (Long)q.uniqueResult();
3816 }
3817 catch (Exception e) {
3818 throw processException(e);
3819 }
3820 finally {
3821 if (count == null) {
3822 count = Long.valueOf(0);
3823 }
3824
3825 FinderCacheUtil.putResult(FINDER_PATH_GET_PERMISSIONS_SIZE,
3826 finderArgs, count);
3827
3828 closeSession(session);
3829 }
3830 }
3831
3832 return count.intValue();
3833 }
3834
3835 public static final FinderPath FINDER_PATH_CONTAINS_PERMISSION = new FinderPath(com.liferay.portal.model.impl.PermissionModelImpl.ENTITY_CACHE_ENABLED,
3836 UserModelImpl.FINDER_CACHE_ENABLED_USERS_PERMISSIONS,
3837 "Users_Permissions", "containsPermission",
3838 new String[] { Long.class.getName(), Long.class.getName() });
3839
3840 public boolean containsPermission(long pk, long permissionPK)
3841 throws SystemException {
3842 Object[] finderArgs = new Object[] { new Long(pk), new Long(permissionPK) };
3843
3844 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_PERMISSION,
3845 finderArgs, this);
3846
3847 if (value == null) {
3848 try {
3849 value = Boolean.valueOf(containsPermission.contains(pk,
3850 permissionPK));
3851 }
3852 catch (Exception e) {
3853 throw processException(e);
3854 }
3855 finally {
3856 if (value == null) {
3857 value = Boolean.FALSE;
3858 }
3859
3860 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_PERMISSION,
3861 finderArgs, value);
3862 }
3863 }
3864
3865 return value.booleanValue();
3866 }
3867
3868 public boolean containsPermissions(long pk) throws SystemException {
3869 if (getPermissionsSize(pk) > 0) {
3870 return true;
3871 }
3872 else {
3873 return false;
3874 }
3875 }
3876
3877 public void addPermission(long pk, long permissionPK)
3878 throws SystemException {
3879 try {
3880 addPermission.add(pk, permissionPK);
3881 }
3882 catch (Exception e) {
3883 throw processException(e);
3884 }
3885 finally {
3886 FinderCacheUtil.clearCache("Users_Permissions");
3887 }
3888 }
3889
3890 public void addPermission(long pk,
3891 com.liferay.portal.model.Permission permission)
3892 throws SystemException {
3893 try {
3894 addPermission.add(pk, permission.getPrimaryKey());
3895 }
3896 catch (Exception e) {
3897 throw processException(e);
3898 }
3899 finally {
3900 FinderCacheUtil.clearCache("Users_Permissions");
3901 }
3902 }
3903
3904 public void addPermissions(long pk, long[] permissionPKs)
3905 throws SystemException {
3906 try {
3907 for (long permissionPK : permissionPKs) {
3908 addPermission.add(pk, permissionPK);
3909 }
3910 }
3911 catch (Exception e) {
3912 throw processException(e);
3913 }
3914 finally {
3915 FinderCacheUtil.clearCache("Users_Permissions");
3916 }
3917 }
3918
3919 public void addPermissions(long pk,
3920 List<com.liferay.portal.model.Permission> permissions)
3921 throws SystemException {
3922 try {
3923 for (com.liferay.portal.model.Permission permission : permissions) {
3924 addPermission.add(pk, permission.getPrimaryKey());
3925 }
3926 }
3927 catch (Exception e) {
3928 throw processException(e);
3929 }
3930 finally {
3931 FinderCacheUtil.clearCache("Users_Permissions");
3932 }
3933 }
3934
3935 public void clearPermissions(long pk) throws SystemException {
3936 try {
3937 clearPermissions.clear(pk);
3938 }
3939 catch (Exception e) {
3940 throw processException(e);
3941 }
3942 finally {
3943 FinderCacheUtil.clearCache("Users_Permissions");
3944 }
3945 }
3946
3947 public void removePermission(long pk, long permissionPK)
3948 throws SystemException {
3949 try {
3950 removePermission.remove(pk, permissionPK);
3951 }
3952 catch (Exception e) {
3953 throw processException(e);
3954 }
3955 finally {
3956 FinderCacheUtil.clearCache("Users_Permissions");
3957 }
3958 }
3959
3960 public void removePermission(long pk,
3961 com.liferay.portal.model.Permission permission)
3962 throws SystemException {
3963 try {
3964 removePermission.remove(pk, permission.getPrimaryKey());
3965 }
3966 catch (Exception e) {
3967 throw processException(e);
3968 }
3969 finally {
3970 FinderCacheUtil.clearCache("Users_Permissions");
3971 }
3972 }
3973
3974 public void removePermissions(long pk, long[] permissionPKs)
3975 throws SystemException {
3976 try {
3977 for (long permissionPK : permissionPKs) {
3978 removePermission.remove(pk, permissionPK);
3979 }
3980 }
3981 catch (Exception e) {
3982 throw processException(e);
3983 }
3984 finally {
3985 FinderCacheUtil.clearCache("Users_Permissions");
3986 }
3987 }
3988
3989 public void removePermissions(long pk,
3990 List<com.liferay.portal.model.Permission> permissions)
3991 throws SystemException {
3992 try {
3993 for (com.liferay.portal.model.Permission permission : permissions) {
3994 removePermission.remove(pk, permission.getPrimaryKey());
3995 }
3996 }
3997 catch (Exception e) {
3998 throw processException(e);
3999 }
4000 finally {
4001 FinderCacheUtil.clearCache("Users_Permissions");
4002 }
4003 }
4004
4005 public void setPermissions(long pk, long[] permissionPKs)
4006 throws SystemException {
4007 try {
4008 Set<Long> permissionPKSet = SetUtil.fromArray(permissionPKs);
4009
4010 List<com.liferay.portal.model.Permission> permissions = getPermissions(pk);
4011
4012 for (com.liferay.portal.model.Permission permission : permissions) {
4013 if (!permissionPKSet.contains(permission.getPrimaryKey())) {
4014 removePermission.remove(pk, permission.getPrimaryKey());
4015 }
4016 else {
4017 permissionPKSet.remove(permission.getPrimaryKey());
4018 }
4019 }
4020
4021 for (Long permissionPK : permissionPKSet) {
4022 addPermission.add(pk, permissionPK);
4023 }
4024 }
4025 catch (Exception e) {
4026 throw processException(e);
4027 }
4028 finally {
4029 FinderCacheUtil.clearCache("Users_Permissions");
4030 }
4031 }
4032
4033 public void setPermissions(long pk,
4034 List<com.liferay.portal.model.Permission> permissions)
4035 throws SystemException {
4036 try {
4037 long[] permissionPKs = new long[permissions.size()];
4038
4039 for (int i = 0; i < permissions.size(); i++) {
4040 com.liferay.portal.model.Permission permission = permissions.get(i);
4041
4042 permissionPKs[i] = permission.getPrimaryKey();
4043 }
4044
4045 setPermissions(pk, permissionPKs);
4046 }
4047 catch (Exception e) {
4048 throw processException(e);
4049 }
4050 finally {
4051 FinderCacheUtil.clearCache("Users_Permissions");
4052 }
4053 }
4054
4055 public List<com.liferay.portal.model.Role> getRoles(long pk)
4056 throws SystemException {
4057 return getRoles(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
4058 }
4059
4060 public List<com.liferay.portal.model.Role> getRoles(long pk, int start,
4061 int end) throws SystemException {
4062 return getRoles(pk, start, end, null);
4063 }
4064
4065 public static final FinderPath FINDER_PATH_GET_ROLES = new FinderPath(com.liferay.portal.model.impl.RoleModelImpl.ENTITY_CACHE_ENABLED,
4066 UserModelImpl.FINDER_CACHE_ENABLED_USERS_ROLES, "Users_Roles",
4067 "getRoles",
4068 new String[] {
4069 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
4070 "com.liferay.portal.kernel.util.OrderByComparator"
4071 });
4072
4073 public List<com.liferay.portal.model.Role> getRoles(long pk, int start,
4074 int end, OrderByComparator obc) throws SystemException {
4075 Object[] finderArgs = new Object[] {
4076 new Long(pk), String.valueOf(start), String.valueOf(end),
4077 String.valueOf(obc)
4078 };
4079
4080 List<com.liferay.portal.model.Role> list = (List<com.liferay.portal.model.Role>)FinderCacheUtil.getResult(FINDER_PATH_GET_ROLES,
4081 finderArgs, this);
4082
4083 if (list == null) {
4084 Session session = null;
4085
4086 try {
4087 session = openSession();
4088
4089 StringBuilder sb = new StringBuilder();
4090
4091 sb.append(_SQL_GETROLES);
4092
4093 if (obc != null) {
4094 sb.append("ORDER BY ");
4095 sb.append(obc.getOrderBy());
4096 }
4097
4098 else {
4099 sb.append("ORDER BY ");
4100
4101 sb.append("Role_.name ASC");
4102 }
4103
4104 String sql = sb.toString();
4105
4106 SQLQuery q = session.createSQLQuery(sql);
4107
4108 q.addEntity("Role_",
4109 com.liferay.portal.model.impl.RoleImpl.class);
4110
4111 QueryPos qPos = QueryPos.getInstance(q);
4112
4113 qPos.add(pk);
4114
4115 list = (List<com.liferay.portal.model.Role>)QueryUtil.list(q,
4116 getDialect(), start, end);
4117 }
4118 catch (Exception e) {
4119 throw processException(e);
4120 }
4121 finally {
4122 if (list == null) {
4123 list = new ArrayList<com.liferay.portal.model.Role>();
4124 }
4125
4126 rolePersistence.cacheResult(list);
4127
4128 FinderCacheUtil.putResult(FINDER_PATH_GET_ROLES, finderArgs,
4129 list);
4130
4131 closeSession(session);
4132 }
4133 }
4134
4135 return list;
4136 }
4137
4138 public static final FinderPath FINDER_PATH_GET_ROLES_SIZE = new FinderPath(com.liferay.portal.model.impl.RoleModelImpl.ENTITY_CACHE_ENABLED,
4139 UserModelImpl.FINDER_CACHE_ENABLED_USERS_ROLES, "Users_Roles",
4140 "getRolesSize", new String[] { Long.class.getName() });
4141
4142 public int getRolesSize(long pk) throws SystemException {
4143 Object[] finderArgs = new Object[] { new Long(pk) };
4144
4145 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_ROLES_SIZE,
4146 finderArgs, this);
4147
4148 if (count == null) {
4149 Session session = null;
4150
4151 try {
4152 session = openSession();
4153
4154 SQLQuery q = session.createSQLQuery(_SQL_GETROLESSIZE);
4155
4156 q.addScalar(COUNT_COLUMN_NAME, Type.LONG);
4157
4158 QueryPos qPos = QueryPos.getInstance(q);
4159
4160 qPos.add(pk);
4161
4162 count = (Long)q.uniqueResult();
4163 }
4164 catch (Exception e) {
4165 throw processException(e);
4166 }
4167 finally {
4168 if (count == null) {
4169 count = Long.valueOf(0);
4170 }
4171
4172 FinderCacheUtil.putResult(FINDER_PATH_GET_ROLES_SIZE,
4173 finderArgs, count);
4174
4175 closeSession(session);
4176 }
4177 }
4178
4179 return count.intValue();
4180 }
4181
4182 public static final FinderPath FINDER_PATH_CONTAINS_ROLE = new FinderPath(com.liferay.portal.model.impl.RoleModelImpl.ENTITY_CACHE_ENABLED,
4183 UserModelImpl.FINDER_CACHE_ENABLED_USERS_ROLES, "Users_Roles",
4184 "containsRole",
4185 new String[] { Long.class.getName(), Long.class.getName() });
4186
4187 public boolean containsRole(long pk, long rolePK) throws SystemException {
4188 Object[] finderArgs = new Object[] { new Long(pk), new Long(rolePK) };
4189
4190 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_ROLE,
4191 finderArgs, this);
4192
4193 if (value == null) {
4194 try {
4195 value = Boolean.valueOf(containsRole.contains(pk, rolePK));
4196 }
4197 catch (Exception e) {
4198 throw processException(e);
4199 }
4200 finally {
4201 if (value == null) {
4202 value = Boolean.FALSE;
4203 }
4204
4205 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_ROLE,
4206 finderArgs, value);
4207 }
4208 }
4209
4210 return value.booleanValue();
4211 }
4212
4213 public boolean containsRoles(long pk) throws SystemException {
4214 if (getRolesSize(pk) > 0) {
4215 return true;
4216 }
4217 else {
4218 return false;
4219 }
4220 }
4221
4222 public void addRole(long pk, long rolePK) throws SystemException {
4223 try {
4224 addRole.add(pk, rolePK);
4225 }
4226 catch (Exception e) {
4227 throw processException(e);
4228 }
4229 finally {
4230 FinderCacheUtil.clearCache("Users_Roles");
4231 }
4232 }
4233
4234 public void addRole(long pk, com.liferay.portal.model.Role role)
4235 throws SystemException {
4236 try {
4237 addRole.add(pk, role.getPrimaryKey());
4238 }
4239 catch (Exception e) {
4240 throw processException(e);
4241 }
4242 finally {
4243 FinderCacheUtil.clearCache("Users_Roles");
4244 }
4245 }
4246
4247 public void addRoles(long pk, long[] rolePKs) throws SystemException {
4248 try {
4249 for (long rolePK : rolePKs) {
4250 addRole.add(pk, rolePK);
4251 }
4252 }
4253 catch (Exception e) {
4254 throw processException(e);
4255 }
4256 finally {
4257 FinderCacheUtil.clearCache("Users_Roles");
4258 }
4259 }
4260
4261 public void addRoles(long pk, List<com.liferay.portal.model.Role> roles)
4262 throws SystemException {
4263 try {
4264 for (com.liferay.portal.model.Role role : roles) {
4265 addRole.add(pk, role.getPrimaryKey());
4266 }
4267 }
4268 catch (Exception e) {
4269 throw processException(e);
4270 }
4271 finally {
4272 FinderCacheUtil.clearCache("Users_Roles");
4273 }
4274 }
4275
4276 public void clearRoles(long pk) throws SystemException {
4277 try {
4278 clearRoles.clear(pk);
4279 }
4280 catch (Exception e) {
4281 throw processException(e);
4282 }
4283 finally {
4284 FinderCacheUtil.clearCache("Users_Roles");
4285 }
4286 }
4287
4288 public void removeRole(long pk, long rolePK) throws SystemException {
4289 try {
4290 removeRole.remove(pk, rolePK);
4291 }
4292 catch (Exception e) {
4293 throw processException(e);
4294 }
4295 finally {
4296 FinderCacheUtil.clearCache("Users_Roles");
4297 }
4298 }
4299
4300 public void removeRole(long pk, com.liferay.portal.model.Role role)
4301 throws SystemException {
4302 try {
4303 removeRole.remove(pk, role.getPrimaryKey());
4304 }
4305 catch (Exception e) {
4306 throw processException(e);
4307 }
4308 finally {
4309 FinderCacheUtil.clearCache("Users_Roles");
4310 }
4311 }
4312
4313 public void removeRoles(long pk, long[] rolePKs) throws SystemException {
4314 try {
4315 for (long rolePK : rolePKs) {
4316 removeRole.remove(pk, rolePK);
4317 }
4318 }
4319 catch (Exception e) {
4320 throw processException(e);
4321 }
4322 finally {
4323 FinderCacheUtil.clearCache("Users_Roles");
4324 }
4325 }
4326
4327 public void removeRoles(long pk, List<com.liferay.portal.model.Role> roles)
4328 throws SystemException {
4329 try {
4330 for (com.liferay.portal.model.Role role : roles) {
4331 removeRole.remove(pk, role.getPrimaryKey());
4332 }
4333 }
4334 catch (Exception e) {
4335 throw processException(e);
4336 }
4337 finally {
4338 FinderCacheUtil.clearCache("Users_Roles");
4339 }
4340 }
4341
4342 public void setRoles(long pk, long[] rolePKs) throws SystemException {
4343 try {
4344 Set<Long> rolePKSet = SetUtil.fromArray(rolePKs);
4345
4346 List<com.liferay.portal.model.Role> roles = getRoles(pk);
4347
4348 for (com.liferay.portal.model.Role role : roles) {
4349 if (!rolePKSet.contains(role.getPrimaryKey())) {
4350 removeRole.remove(pk, role.getPrimaryKey());
4351 }
4352 else {
4353 rolePKSet.remove(role.getPrimaryKey());
4354 }
4355 }
4356
4357 for (Long rolePK : rolePKSet) {
4358 addRole.add(pk, rolePK);
4359 }
4360 }
4361 catch (Exception e) {
4362 throw processException(e);
4363 }
4364 finally {
4365 FinderCacheUtil.clearCache("Users_Roles");
4366 }
4367 }
4368
4369 public void setRoles(long pk, List<com.liferay.portal.model.Role> roles)
4370 throws SystemException {
4371 try {
4372 long[] rolePKs = new long[roles.size()];
4373
4374 for (int i = 0; i < roles.size(); i++) {
4375 com.liferay.portal.model.Role role = roles.get(i);
4376
4377 rolePKs[i] = role.getPrimaryKey();
4378 }
4379
4380 setRoles(pk, rolePKs);
4381 }
4382 catch (Exception e) {
4383 throw processException(e);
4384 }
4385 finally {
4386 FinderCacheUtil.clearCache("Users_Roles");
4387 }
4388 }
4389
4390 public List<com.liferay.portal.model.UserGroup> getUserGroups(long pk)
4391 throws SystemException {
4392 return getUserGroups(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
4393 }
4394
4395 public List<com.liferay.portal.model.UserGroup> getUserGroups(long pk,
4396 int start, int end) throws SystemException {
4397 return getUserGroups(pk, start, end, null);
4398 }
4399
4400 public static final FinderPath FINDER_PATH_GET_USERGROUPS = new FinderPath(com.liferay.portal.model.impl.UserGroupModelImpl.ENTITY_CACHE_ENABLED,
4401 UserModelImpl.FINDER_CACHE_ENABLED_USERS_USERGROUPS,
4402 "Users_UserGroups", "getUserGroups",
4403 new String[] {
4404 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
4405 "com.liferay.portal.kernel.util.OrderByComparator"
4406 });
4407
4408 public List<com.liferay.portal.model.UserGroup> getUserGroups(long pk,
4409 int start, int end, OrderByComparator obc) throws SystemException {
4410 Object[] finderArgs = new Object[] {
4411 new Long(pk), String.valueOf(start), String.valueOf(end),
4412 String.valueOf(obc)
4413 };
4414
4415 List<com.liferay.portal.model.UserGroup> list = (List<com.liferay.portal.model.UserGroup>)FinderCacheUtil.getResult(FINDER_PATH_GET_USERGROUPS,
4416 finderArgs, this);
4417
4418 if (list == null) {
4419 Session session = null;
4420
4421 try {
4422 session = openSession();
4423
4424 StringBuilder sb = new StringBuilder();
4425
4426 sb.append(_SQL_GETUSERGROUPS);
4427
4428 if (obc != null) {
4429 sb.append("ORDER BY ");
4430 sb.append(obc.getOrderBy());
4431 }
4432
4433 else {
4434 sb.append("ORDER BY ");
4435
4436 sb.append("UserGroup.name ASC");
4437 }
4438
4439 String sql = sb.toString();
4440
4441 SQLQuery q = session.createSQLQuery(sql);
4442
4443 q.addEntity("UserGroup",
4444 com.liferay.portal.model.impl.UserGroupImpl.class);
4445
4446 QueryPos qPos = QueryPos.getInstance(q);
4447
4448 qPos.add(pk);
4449
4450 list = (List<com.liferay.portal.model.UserGroup>)QueryUtil.list(q,
4451 getDialect(), start, end);
4452 }
4453 catch (Exception e) {
4454 throw processException(e);
4455 }
4456 finally {
4457 if (list == null) {
4458 list = new ArrayList<com.liferay.portal.model.UserGroup>();
4459 }
4460
4461 userGroupPersistence.cacheResult(list);
4462
4463 FinderCacheUtil.putResult(FINDER_PATH_GET_USERGROUPS,
4464 finderArgs, list);
4465
4466 closeSession(session);
4467 }
4468 }
4469
4470 return list;
4471 }
4472
4473 public static final FinderPath FINDER_PATH_GET_USERGROUPS_SIZE = new FinderPath(com.liferay.portal.model.impl.UserGroupModelImpl.ENTITY_CACHE_ENABLED,
4474 UserModelImpl.FINDER_CACHE_ENABLED_USERS_USERGROUPS,
4475 "Users_UserGroups", "getUserGroupsSize",
4476 new String[] { Long.class.getName() });
4477
4478 public int getUserGroupsSize(long pk) throws SystemException {
4479 Object[] finderArgs = new Object[] { new Long(pk) };
4480
4481 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_USERGROUPS_SIZE,
4482 finderArgs, this);
4483
4484 if (count == null) {
4485 Session session = null;
4486
4487 try {
4488 session = openSession();
4489
4490 SQLQuery q = session.createSQLQuery(_SQL_GETUSERGROUPSSIZE);
4491
4492 q.addScalar(COUNT_COLUMN_NAME, Type.LONG);
4493
4494 QueryPos qPos = QueryPos.getInstance(q);
4495
4496 qPos.add(pk);
4497
4498 count = (Long)q.uniqueResult();
4499 }
4500 catch (Exception e) {
4501 throw processException(e);
4502 }
4503 finally {
4504 if (count == null) {
4505 count = Long.valueOf(0);
4506 }
4507
4508 FinderCacheUtil.putResult(FINDER_PATH_GET_USERGROUPS_SIZE,
4509 finderArgs, count);
4510
4511 closeSession(session);
4512 }
4513 }
4514
4515 return count.intValue();
4516 }
4517
4518 public static final FinderPath FINDER_PATH_CONTAINS_USERGROUP = new FinderPath(com.liferay.portal.model.impl.UserGroupModelImpl.ENTITY_CACHE_ENABLED,
4519 UserModelImpl.FINDER_CACHE_ENABLED_USERS_USERGROUPS,
4520 "Users_UserGroups", "containsUserGroup",
4521 new String[] { Long.class.getName(), Long.class.getName() });
4522
4523 public boolean containsUserGroup(long pk, long userGroupPK)
4524 throws SystemException {
4525 Object[] finderArgs = new Object[] { new Long(pk), new Long(userGroupPK) };
4526
4527 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_USERGROUP,
4528 finderArgs, this);
4529
4530 if (value == null) {
4531 try {
4532 value = Boolean.valueOf(containsUserGroup.contains(pk,
4533 userGroupPK));
4534 }
4535 catch (Exception e) {
4536 throw processException(e);
4537 }
4538 finally {
4539 if (value == null) {
4540 value = Boolean.FALSE;
4541 }
4542
4543 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_USERGROUP,
4544 finderArgs, value);
4545 }
4546 }
4547
4548 return value.booleanValue();
4549 }
4550
4551 public boolean containsUserGroups(long pk) throws SystemException {
4552 if (getUserGroupsSize(pk) > 0) {
4553 return true;
4554 }
4555 else {
4556 return false;
4557 }
4558 }
4559
4560 public void addUserGroup(long pk, long userGroupPK)
4561 throws SystemException {
4562 try {
4563 addUserGroup.add(pk, userGroupPK);
4564 }
4565 catch (Exception e) {
4566 throw processException(e);
4567 }
4568 finally {
4569 FinderCacheUtil.clearCache("Users_UserGroups");
4570 }
4571 }
4572
4573 public void addUserGroup(long pk,
4574 com.liferay.portal.model.UserGroup userGroup) throws SystemException {
4575 try {
4576 addUserGroup.add(pk, userGroup.getPrimaryKey());
4577 }
4578 catch (Exception e) {
4579 throw processException(e);
4580 }
4581 finally {
4582 FinderCacheUtil.clearCache("Users_UserGroups");
4583 }
4584 }
4585
4586 public void addUserGroups(long pk, long[] userGroupPKs)
4587 throws SystemException {
4588 try {
4589 for (long userGroupPK : userGroupPKs) {
4590 addUserGroup.add(pk, userGroupPK);
4591 }
4592 }
4593 catch (Exception e) {
4594 throw processException(e);
4595 }
4596 finally {
4597 FinderCacheUtil.clearCache("Users_UserGroups");
4598 }
4599 }
4600
4601 public void addUserGroups(long pk,
4602 List<com.liferay.portal.model.UserGroup> userGroups)
4603 throws SystemException {
4604 try {
4605 for (com.liferay.portal.model.UserGroup userGroup : userGroups) {
4606 addUserGroup.add(pk, userGroup.getPrimaryKey());
4607 }
4608 }
4609 catch (Exception e) {
4610 throw processException(e);
4611 }
4612 finally {
4613 FinderCacheUtil.clearCache("Users_UserGroups");
4614 }
4615 }
4616
4617 public void clearUserGroups(long pk) throws SystemException {
4618 try {
4619 clearUserGroups.clear(pk);
4620 }
4621 catch (Exception e) {
4622 throw processException(e);
4623 }
4624 finally {
4625 FinderCacheUtil.clearCache("Users_UserGroups");
4626 }
4627 }
4628
4629 public void removeUserGroup(long pk, long userGroupPK)
4630 throws SystemException {
4631 try {
4632 removeUserGroup.remove(pk, userGroupPK);
4633 }
4634 catch (Exception e) {
4635 throw processException(e);
4636 }
4637 finally {
4638 FinderCacheUtil.clearCache("Users_UserGroups");
4639 }
4640 }
4641
4642 public void removeUserGroup(long pk,
4643 com.liferay.portal.model.UserGroup userGroup) throws SystemException {
4644 try {
4645 removeUserGroup.remove(pk, userGroup.getPrimaryKey());
4646 }
4647 catch (Exception e) {
4648 throw processException(e);
4649 }
4650 finally {
4651 FinderCacheUtil.clearCache("Users_UserGroups");
4652 }
4653 }
4654
4655 public void removeUserGroups(long pk, long[] userGroupPKs)
4656 throws SystemException {
4657 try {
4658 for (long userGroupPK : userGroupPKs) {
4659 removeUserGroup.remove(pk, userGroupPK);
4660 }
4661 }
4662 catch (Exception e) {
4663 throw processException(e);
4664 }
4665 finally {
4666 FinderCacheUtil.clearCache("Users_UserGroups");
4667 }
4668 }
4669
4670 public void removeUserGroups(long pk,
4671 List<com.liferay.portal.model.UserGroup> userGroups)
4672 throws SystemException {
4673 try {
4674 for (com.liferay.portal.model.UserGroup userGroup : userGroups) {
4675 removeUserGroup.remove(pk, userGroup.getPrimaryKey());
4676 }
4677 }
4678 catch (Exception e) {
4679 throw processException(e);
4680 }
4681 finally {
4682 FinderCacheUtil.clearCache("Users_UserGroups");
4683 }
4684 }
4685
4686 public void setUserGroups(long pk, long[] userGroupPKs)
4687 throws SystemException {
4688 try {
4689 Set<Long> userGroupPKSet = SetUtil.fromArray(userGroupPKs);
4690
4691 List<com.liferay.portal.model.UserGroup> userGroups = getUserGroups(pk);
4692
4693 for (com.liferay.portal.model.UserGroup userGroup : userGroups) {
4694 if (!userGroupPKSet.contains(userGroup.getPrimaryKey())) {
4695 removeUserGroup.remove(pk, userGroup.getPrimaryKey());
4696 }
4697 else {
4698 userGroupPKSet.remove(userGroup.getPrimaryKey());
4699 }
4700 }
4701
4702 for (Long userGroupPK : userGroupPKSet) {
4703 addUserGroup.add(pk, userGroupPK);
4704 }
4705 }
4706 catch (Exception e) {
4707 throw processException(e);
4708 }
4709 finally {
4710 FinderCacheUtil.clearCache("Users_UserGroups");
4711 }
4712 }
4713
4714 public void setUserGroups(long pk,
4715 List<com.liferay.portal.model.UserGroup> userGroups)
4716 throws SystemException {
4717 try {
4718 long[] userGroupPKs = new long[userGroups.size()];
4719
4720 for (int i = 0; i < userGroups.size(); i++) {
4721 com.liferay.portal.model.UserGroup userGroup = userGroups.get(i);
4722
4723 userGroupPKs[i] = userGroup.getPrimaryKey();
4724 }
4725
4726 setUserGroups(pk, userGroupPKs);
4727 }
4728 catch (Exception e) {
4729 throw processException(e);
4730 }
4731 finally {
4732 FinderCacheUtil.clearCache("Users_UserGroups");
4733 }
4734 }
4735
4736 public void afterPropertiesSet() {
4737 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
4738 com.liferay.portal.util.PropsUtil.get(
4739 "value.object.listener.com.liferay.portal.model.User")));
4740
4741 if (listenerClassNames.length > 0) {
4742 try {
4743 List<ModelListener<User>> listenersList = new ArrayList<ModelListener<User>>();
4744
4745 for (String listenerClassName : listenerClassNames) {
4746 listenersList.add((ModelListener<User>)Class.forName(
4747 listenerClassName).newInstance());
4748 }
4749
4750 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
4751 }
4752 catch (Exception e) {
4753 _log.error(e);
4754 }
4755 }
4756
4757 containsGroup = new ContainsGroup(this);
4758
4759 addGroup = new AddGroup(this);
4760 clearGroups = new ClearGroups(this);
4761 removeGroup = new RemoveGroup(this);
4762
4763 containsOrganization = new ContainsOrganization(this);
4764
4765 addOrganization = new AddOrganization(this);
4766 clearOrganizations = new ClearOrganizations(this);
4767 removeOrganization = new RemoveOrganization(this);
4768
4769 containsPermission = new ContainsPermission(this);
4770
4771 addPermission = new AddPermission(this);
4772 clearPermissions = new ClearPermissions(this);
4773 removePermission = new RemovePermission(this);
4774
4775 containsRole = new ContainsRole(this);
4776
4777 addRole = new AddRole(this);
4778 clearRoles = new ClearRoles(this);
4779 removeRole = new RemoveRole(this);
4780
4781 containsUserGroup = new ContainsUserGroup(this);
4782
4783 addUserGroup = new AddUserGroup(this);
4784 clearUserGroups = new ClearUserGroups(this);
4785 removeUserGroup = new RemoveUserGroup(this);
4786 }
4787
4788 @BeanReference(name = "com.liferay.portal.service.persistence.AccountPersistence.impl")
4789 protected com.liferay.portal.service.persistence.AccountPersistence accountPersistence;
4790 @BeanReference(name = "com.liferay.portal.service.persistence.AddressPersistence.impl")
4791 protected com.liferay.portal.service.persistence.AddressPersistence addressPersistence;
4792 @BeanReference(name = "com.liferay.portal.service.persistence.BrowserTrackerPersistence.impl")
4793 protected com.liferay.portal.service.persistence.BrowserTrackerPersistence browserTrackerPersistence;
4794 @BeanReference(name = "com.liferay.portal.service.persistence.ClassNamePersistence.impl")
4795 protected com.liferay.portal.service.persistence.ClassNamePersistence classNamePersistence;
4796 @BeanReference(name = "com.liferay.portal.service.persistence.CompanyPersistence.impl")
4797 protected com.liferay.portal.service.persistence.CompanyPersistence companyPersistence;
4798 @BeanReference(name = "com.liferay.portal.service.persistence.ContactPersistence.impl")
4799 protected com.liferay.portal.service.persistence.ContactPersistence contactPersistence;
4800 @BeanReference(name = "com.liferay.portal.service.persistence.CountryPersistence.impl")
4801 protected com.liferay.portal.service.persistence.CountryPersistence countryPersistence;
4802 @BeanReference(name = "com.liferay.portal.service.persistence.EmailAddressPersistence.impl")
4803 protected com.liferay.portal.service.persistence.EmailAddressPersistence emailAddressPersistence;
4804 @BeanReference(name = "com.liferay.portal.service.persistence.GroupPersistence.impl")
4805 protected com.liferay.portal.service.persistence.GroupPersistence groupPersistence;
4806 @BeanReference(name = "com.liferay.portal.service.persistence.ImagePersistence.impl")
4807 protected com.liferay.portal.service.persistence.ImagePersistence imagePersistence;
4808 @BeanReference(name = "com.liferay.portal.service.persistence.LayoutPersistence.impl")
4809 protected com.liferay.portal.service.persistence.LayoutPersistence layoutPersistence;
4810 @BeanReference(name = "com.liferay.portal.service.persistence.LayoutSetPersistence.impl")
4811 protected com.liferay.portal.service.persistence.LayoutSetPersistence layoutSetPersistence;
4812 @BeanReference(name = "com.liferay.portal.service.persistence.ListTypePersistence.impl")
4813 protected com.liferay.portal.service.persistence.ListTypePersistence listTypePersistence;
4814 @BeanReference(name = "com.liferay.portal.service.persistence.LockPersistence.impl")
4815 protected com.liferay.portal.service.persistence.LockPersistence lockPersistence;
4816 @BeanReference(name = "com.liferay.portal.service.persistence.MembershipRequestPersistence.impl")
4817 protected com.liferay.portal.service.persistence.MembershipRequestPersistence membershipRequestPersistence;
4818 @BeanReference(name = "com.liferay.portal.service.persistence.OrganizationPersistence.impl")
4819 protected com.liferay.portal.service.persistence.OrganizationPersistence organizationPersistence;
4820 @BeanReference(name = "com.liferay.portal.service.persistence.OrgGroupPermissionPersistence.impl")
4821 protected com.liferay.portal.service.persistence.OrgGroupPermissionPersistence orgGroupPermissionPersistence;
4822 @BeanReference(name = "com.liferay.portal.service.persistence.OrgGroupRolePersistence.impl")
4823 protected com.liferay.portal.service.persistence.OrgGroupRolePersistence orgGroupRolePersistence;
4824 @BeanReference(name = "com.liferay.portal.service.persistence.OrgLaborPersistence.impl")
4825 protected com.liferay.portal.service.persistence.OrgLaborPersistence orgLaborPersistence;
4826 @BeanReference(name = "com.liferay.portal.service.persistence.PasswordPolicyPersistence.impl")
4827 protected com.liferay.portal.service.persistence.PasswordPolicyPersistence passwordPolicyPersistence;
4828 @BeanReference(name = "com.liferay.portal.service.persistence.PasswordPolicyRelPersistence.impl")
4829 protected com.liferay.portal.service.persistence.PasswordPolicyRelPersistence passwordPolicyRelPersistence;
4830 @BeanReference(name = "com.liferay.portal.service.persistence.PasswordTrackerPersistence.impl")
4831 protected com.liferay.portal.service.persistence.PasswordTrackerPersistence passwordTrackerPersistence;
4832 @BeanReference(name = "com.liferay.portal.service.persistence.PermissionPersistence.impl")
4833 protected com.liferay.portal.service.persistence.PermissionPersistence permissionPersistence;
4834 @BeanReference(name = "com.liferay.portal.service.persistence.PhonePersistence.impl")
4835 protected com.liferay.portal.service.persistence.PhonePersistence phonePersistence;
4836 @BeanReference(name = "com.liferay.portal.service.persistence.PluginSettingPersistence.impl")
4837 protected com.liferay.portal.service.persistence.PluginSettingPersistence pluginSettingPersistence;
4838 @BeanReference(name = "com.liferay.portal.service.persistence.PortletPersistence.impl")
4839 protected com.liferay.portal.service.persistence.PortletPersistence portletPersistence;
4840 @BeanReference(name = "com.liferay.portal.service.persistence.PortletItemPersistence.impl")
4841 protected com.liferay.portal.service.persistence.PortletItemPersistence portletItemPersistence;
4842 @BeanReference(name = "com.liferay.portal.service.persistence.PortletPreferencesPersistence.impl")
4843 protected com.liferay.portal.service.persistence.PortletPreferencesPersistence portletPreferencesPersistence;
4844 @BeanReference(name = "com.liferay.portal.service.persistence.RegionPersistence.impl")
4845 protected com.liferay.portal.service.persistence.RegionPersistence regionPersistence;
4846 @BeanReference(name = "com.liferay.portal.service.persistence.ReleasePersistence.impl")
4847 protected com.liferay.portal.service.persistence.ReleasePersistence releasePersistence;
4848 @BeanReference(name = "com.liferay.portal.service.persistence.ResourcePersistence.impl")
4849 protected com.liferay.portal.service.persistence.ResourcePersistence resourcePersistence;
4850 @BeanReference(name = "com.liferay.portal.service.persistence.ResourceActionPersistence.impl")
4851 protected com.liferay.portal.service.persistence.ResourceActionPersistence resourceActionPersistence;
4852 @BeanReference(name = "com.liferay.portal.service.persistence.ResourceCodePersistence.impl")
4853 protected com.liferay.portal.service.persistence.ResourceCodePersistence resourceCodePersistence;
4854 @BeanReference(name = "com.liferay.portal.service.persistence.ResourcePermissionPersistence.impl")
4855 protected com.liferay.portal.service.persistence.ResourcePermissionPersistence resourcePermissionPersistence;
4856 @BeanReference(name = "com.liferay.portal.service.persistence.RolePersistence.impl")
4857 protected com.liferay.portal.service.persistence.RolePersistence rolePersistence;
4858 @BeanReference(name = "com.liferay.portal.service.persistence.ServiceComponentPersistence.impl")
4859 protected com.liferay.portal.service.persistence.ServiceComponentPersistence serviceComponentPersistence;
4860 @BeanReference(name = "com.liferay.portal.service.persistence.ShardPersistence.impl")
4861 protected com.liferay.portal.service.persistence.ShardPersistence shardPersistence;
4862 @BeanReference(name = "com.liferay.portal.service.persistence.SubscriptionPersistence.impl")
4863 protected com.liferay.portal.service.persistence.SubscriptionPersistence subscriptionPersistence;
4864 @BeanReference(name = "com.liferay.portal.service.persistence.UserPersistence.impl")
4865 protected com.liferay.portal.service.persistence.UserPersistence userPersistence;
4866 @BeanReference(name = "com.liferay.portal.service.persistence.UserGroupPersistence.impl")
4867 protected com.liferay.portal.service.persistence.UserGroupPersistence userGroupPersistence;
4868 @BeanReference(name = "com.liferay.portal.service.persistence.UserGroupGroupRolePersistence.impl")
4869 protected com.liferay.portal.service.persistence.UserGroupGroupRolePersistence userGroupGroupRolePersistence;
4870 @BeanReference(name = "com.liferay.portal.service.persistence.UserGroupRolePersistence.impl")
4871 protected com.liferay.portal.service.persistence.UserGroupRolePersistence userGroupRolePersistence;
4872 @BeanReference(name = "com.liferay.portal.service.persistence.UserIdMapperPersistence.impl")
4873 protected com.liferay.portal.service.persistence.UserIdMapperPersistence userIdMapperPersistence;
4874 @BeanReference(name = "com.liferay.portal.service.persistence.UserTrackerPersistence.impl")
4875 protected com.liferay.portal.service.persistence.UserTrackerPersistence userTrackerPersistence;
4876 @BeanReference(name = "com.liferay.portal.service.persistence.UserTrackerPathPersistence.impl")
4877 protected com.liferay.portal.service.persistence.UserTrackerPathPersistence userTrackerPathPersistence;
4878 @BeanReference(name = "com.liferay.portal.service.persistence.WebDAVPropsPersistence.impl")
4879 protected com.liferay.portal.service.persistence.WebDAVPropsPersistence webDAVPropsPersistence;
4880 @BeanReference(name = "com.liferay.portal.service.persistence.WebsitePersistence.impl")
4881 protected com.liferay.portal.service.persistence.WebsitePersistence websitePersistence;
4882 @BeanReference(name = "com.liferay.portlet.announcements.service.persistence.AnnouncementsDeliveryPersistence.impl")
4883 protected com.liferay.portlet.announcements.service.persistence.AnnouncementsDeliveryPersistence announcementsDeliveryPersistence;
4884 @BeanReference(name = "com.liferay.portlet.blogs.service.persistence.BlogsStatsUserPersistence.impl")
4885 protected com.liferay.portlet.blogs.service.persistence.BlogsStatsUserPersistence blogsStatsUserPersistence;
4886 @BeanReference(name = "com.liferay.portlet.documentlibrary.service.persistence.DLFileRankPersistence.impl")
4887 protected com.liferay.portlet.documentlibrary.service.persistence.DLFileRankPersistence dlFileRankPersistence;
4888 @BeanReference(name = "com.liferay.portlet.expando.service.persistence.ExpandoValuePersistence.impl")
4889 protected com.liferay.portlet.expando.service.persistence.ExpandoValuePersistence expandoValuePersistence;
4890 @BeanReference(name = "com.liferay.portlet.messageboards.service.persistence.MBBanPersistence.impl")
4891 protected com.liferay.portlet.messageboards.service.persistence.MBBanPersistence mbBanPersistence;
4892 @BeanReference(name = "com.liferay.portlet.messageboards.service.persistence.MBMessageFlagPersistence.impl")
4893 protected com.liferay.portlet.messageboards.service.persistence.MBMessageFlagPersistence mbMessageFlagPersistence;
4894 @BeanReference(name = "com.liferay.portlet.messageboards.service.persistence.MBStatsUserPersistence.impl")
4895 protected com.liferay.portlet.messageboards.service.persistence.MBStatsUserPersistence mbStatsUserPersistence;
4896 @BeanReference(name = "com.liferay.portlet.shopping.service.persistence.ShoppingCartPersistence.impl")
4897 protected com.liferay.portlet.shopping.service.persistence.ShoppingCartPersistence shoppingCartPersistence;
4898 @BeanReference(name = "com.liferay.portlet.social.service.persistence.SocialActivityPersistence.impl")
4899 protected com.liferay.portlet.social.service.persistence.SocialActivityPersistence socialActivityPersistence;
4900 @BeanReference(name = "com.liferay.portlet.social.service.persistence.SocialRequestPersistence.impl")
4901 protected com.liferay.portlet.social.service.persistence.SocialRequestPersistence socialRequestPersistence;
4902 @BeanReference(name = "com.liferay.portlet.tags.service.persistence.TagsAssetPersistence.impl")
4903 protected com.liferay.portlet.tags.service.persistence.TagsAssetPersistence tagsAssetPersistence;
4904 protected ContainsGroup containsGroup;
4905 protected AddGroup addGroup;
4906 protected ClearGroups clearGroups;
4907 protected RemoveGroup removeGroup;
4908 protected ContainsOrganization containsOrganization;
4909 protected AddOrganization addOrganization;
4910 protected ClearOrganizations clearOrganizations;
4911 protected RemoveOrganization removeOrganization;
4912 protected ContainsPermission containsPermission;
4913 protected AddPermission addPermission;
4914 protected ClearPermissions clearPermissions;
4915 protected RemovePermission removePermission;
4916 protected ContainsRole containsRole;
4917 protected AddRole addRole;
4918 protected ClearRoles clearRoles;
4919 protected RemoveRole removeRole;
4920 protected ContainsUserGroup containsUserGroup;
4921 protected AddUserGroup addUserGroup;
4922 protected ClearUserGroups clearUserGroups;
4923 protected RemoveUserGroup removeUserGroup;
4924
4925 protected class ContainsGroup {
4926 protected ContainsGroup(UserPersistenceImpl persistenceImpl) {
4927 super();
4928
4929 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
4930 _SQL_CONTAINSGROUP,
4931 new int[] { Types.BIGINT, Types.BIGINT }, RowMapper.COUNT);
4932 }
4933
4934 protected boolean contains(long userId, long groupId) {
4935 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
4936 new Long(userId), new Long(groupId)
4937 });
4938
4939 if (results.size() > 0) {
4940 Integer count = results.get(0);
4941
4942 if (count.intValue() > 0) {
4943 return true;
4944 }
4945 }
4946
4947 return false;
4948 }
4949
4950 private MappingSqlQuery _mappingSqlQuery;
4951 }
4952
4953 protected class AddGroup {
4954 protected AddGroup(UserPersistenceImpl persistenceImpl) {
4955 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
4956 "INSERT INTO Users_Groups (userId, groupId) VALUES (?, ?)",
4957 new int[] { Types.BIGINT, Types.BIGINT });
4958 _persistenceImpl = persistenceImpl;
4959 }
4960
4961 protected void add(long userId, long groupId) throws SystemException {
4962 if (!_persistenceImpl.containsGroup.contains(userId, groupId)) {
4963 ModelListener<com.liferay.portal.model.Group>[] groupListeners = groupPersistence.getListeners();
4964
4965 for (ModelListener<User> listener : listeners) {
4966 listener.onBeforeAddAssociation(userId,
4967 com.liferay.portal.model.Group.class.getName(), groupId);
4968 }
4969
4970 for (ModelListener<com.liferay.portal.model.Group> listener : groupListeners) {
4971 listener.onBeforeAddAssociation(groupId,
4972 User.class.getName(), userId);
4973 }
4974
4975 _sqlUpdate.update(new Object[] {
4976 new Long(userId), new Long(groupId)
4977 });
4978
4979 for (ModelListener<User> listener : listeners) {
4980 listener.onAfterAddAssociation(userId,
4981 com.liferay.portal.model.Group.class.getName(), groupId);
4982 }
4983
4984 for (ModelListener<com.liferay.portal.model.Group> listener : groupListeners) {
4985 listener.onAfterAddAssociation(groupId,
4986 User.class.getName(), userId);
4987 }
4988 }
4989 }
4990
4991 private SqlUpdate _sqlUpdate;
4992 private UserPersistenceImpl _persistenceImpl;
4993 }
4994
4995 protected class ClearGroups {
4996 protected ClearGroups(UserPersistenceImpl persistenceImpl) {
4997 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
4998 "DELETE FROM Users_Groups WHERE userId = ?",
4999 new int[] { Types.BIGINT });
5000 }
5001
5002 protected void clear(long userId) throws SystemException {
5003 ModelListener<com.liferay.portal.model.Group>[] groupListeners = groupPersistence.getListeners();
5004
5005 List<com.liferay.portal.model.Group> groups = null;
5006
5007 if ((listeners.length > 0) || (groupListeners.length > 0)) {
5008 groups = getGroups(userId);
5009
5010 for (com.liferay.portal.model.Group group : groups) {
5011 for (ModelListener<User> listener : listeners) {
5012 listener.onBeforeRemoveAssociation(userId,
5013 com.liferay.portal.model.Group.class.getName(),
5014 group.getPrimaryKey());
5015 }
5016
5017 for (ModelListener<com.liferay.portal.model.Group> listener : groupListeners) {
5018 listener.onBeforeRemoveAssociation(group.getPrimaryKey(),
5019 User.class.getName(), userId);
5020 }
5021 }
5022 }
5023
5024 _sqlUpdate.update(new Object[] { new Long(userId) });
5025
5026 if ((listeners.length > 0) || (groupListeners.length > 0)) {
5027 for (com.liferay.portal.model.Group group : groups) {
5028 for (ModelListener<User> listener : listeners) {
5029 listener.onAfterRemoveAssociation(userId,
5030 com.liferay.portal.model.Group.class.getName(),
5031 group.getPrimaryKey());
5032 }
5033
5034 for (ModelListener<com.liferay.portal.model.Group> listener : groupListeners) {
5035 listener.onAfterRemoveAssociation(group.getPrimaryKey(),
5036 User.class.getName(), userId);
5037 }
5038 }
5039 }
5040 }
5041
5042 private SqlUpdate _sqlUpdate;
5043 }
5044
5045 protected class RemoveGroup {
5046 protected RemoveGroup(UserPersistenceImpl persistenceImpl) {
5047 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
5048 "DELETE FROM Users_Groups WHERE userId = ? AND groupId = ?",
5049 new int[] { Types.BIGINT, Types.BIGINT });
5050 _persistenceImpl = persistenceImpl;
5051 }
5052
5053 protected void remove(long userId, long groupId)
5054 throws SystemException {
5055 if (_persistenceImpl.containsGroup.contains(userId, groupId)) {
5056 ModelListener<com.liferay.portal.model.Group>[] groupListeners = groupPersistence.getListeners();
5057
5058 for (ModelListener<User> listener : listeners) {
5059 listener.onBeforeRemoveAssociation(userId,
5060 com.liferay.portal.model.Group.class.getName(), groupId);
5061 }
5062
5063 for (ModelListener<com.liferay.portal.model.Group> listener : groupListeners) {
5064 listener.onBeforeRemoveAssociation(groupId,
5065 User.class.getName(), userId);
5066 }
5067
5068 _sqlUpdate.update(new Object[] {
5069 new Long(userId), new Long(groupId)
5070 });
5071
5072 for (ModelListener<User> listener : listeners) {
5073 listener.onAfterRemoveAssociation(userId,
5074 com.liferay.portal.model.Group.class.getName(), groupId);
5075 }
5076
5077 for (ModelListener<com.liferay.portal.model.Group> listener : groupListeners) {
5078 listener.onAfterRemoveAssociation(groupId,
5079 User.class.getName(), userId);
5080 }
5081 }
5082 }
5083
5084 private SqlUpdate _sqlUpdate;
5085 private UserPersistenceImpl _persistenceImpl;
5086 }
5087
5088 protected class ContainsOrganization {
5089 protected ContainsOrganization(UserPersistenceImpl persistenceImpl) {
5090 super();
5091
5092 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
5093 _SQL_CONTAINSORGANIZATION,
5094 new int[] { Types.BIGINT, Types.BIGINT }, RowMapper.COUNT);
5095 }
5096
5097 protected boolean contains(long userId, long organizationId) {
5098 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
5099 new Long(userId), new Long(organizationId)
5100 });
5101
5102 if (results.size() > 0) {
5103 Integer count = results.get(0);
5104
5105 if (count.intValue() > 0) {
5106 return true;
5107 }
5108 }
5109
5110 return false;
5111 }
5112
5113 private MappingSqlQuery _mappingSqlQuery;
5114 }
5115
5116 protected class AddOrganization {
5117 protected AddOrganization(UserPersistenceImpl persistenceImpl) {
5118 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
5119 "INSERT INTO Users_Orgs (userId, organizationId) VALUES (?, ?)",
5120 new int[] { Types.BIGINT, Types.BIGINT });
5121 _persistenceImpl = persistenceImpl;
5122 }
5123
5124 protected void add(long userId, long organizationId)
5125 throws SystemException {
5126 if (!_persistenceImpl.containsOrganization.contains(userId,
5127 organizationId)) {
5128 ModelListener<com.liferay.portal.model.Organization>[] organizationListeners =
5129 organizationPersistence.getListeners();
5130
5131 for (ModelListener<User> listener : listeners) {
5132 listener.onBeforeAddAssociation(userId,
5133 com.liferay.portal.model.Organization.class.getName(),
5134 organizationId);
5135 }
5136
5137 for (ModelListener<com.liferay.portal.model.Organization> listener : organizationListeners) {
5138 listener.onBeforeAddAssociation(organizationId,
5139 User.class.getName(), userId);
5140 }
5141
5142 _sqlUpdate.update(new Object[] {
5143 new Long(userId), new Long(organizationId)
5144 });
5145
5146 for (ModelListener<User> listener : listeners) {
5147 listener.onAfterAddAssociation(userId,
5148 com.liferay.portal.model.Organization.class.getName(),
5149 organizationId);
5150 }
5151
5152 for (ModelListener<com.liferay.portal.model.Organization> listener : organizationListeners) {
5153 listener.onAfterAddAssociation(organizationId,
5154 User.class.getName(), userId);
5155 }
5156 }
5157 }
5158
5159 private SqlUpdate _sqlUpdate;
5160 private UserPersistenceImpl _persistenceImpl;
5161 }
5162
5163 protected class ClearOrganizations {
5164 protected ClearOrganizations(UserPersistenceImpl persistenceImpl) {
5165 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
5166 "DELETE FROM Users_Orgs WHERE userId = ?",
5167 new int[] { Types.BIGINT });
5168 }
5169
5170 protected void clear(long userId) throws SystemException {
5171 ModelListener<com.liferay.portal.model.Organization>[] organizationListeners =
5172 organizationPersistence.getListeners();
5173
5174 List<com.liferay.portal.model.Organization> organizations = null;
5175
5176 if ((listeners.length > 0) || (organizationListeners.length > 0)) {
5177 organizations = getOrganizations(userId);
5178
5179 for (com.liferay.portal.model.Organization organization : organizations) {
5180 for (ModelListener<User> listener : listeners) {
5181 listener.onBeforeRemoveAssociation(userId,
5182 com.liferay.portal.model.Organization.class.getName(),
5183 organization.getPrimaryKey());
5184 }
5185
5186 for (ModelListener<com.liferay.portal.model.Organization> listener : organizationListeners) {
5187 listener.onBeforeRemoveAssociation(organization.getPrimaryKey(),
5188 User.class.getName(), userId);
5189 }
5190 }
5191 }
5192
5193 _sqlUpdate.update(new Object[] { new Long(userId) });
5194
5195 if ((listeners.length > 0) || (organizationListeners.length > 0)) {
5196 for (com.liferay.portal.model.Organization organization : organizations) {
5197 for (ModelListener<User> listener : listeners) {
5198 listener.onAfterRemoveAssociation(userId,
5199 com.liferay.portal.model.Organization.class.getName(),
5200 organization.getPrimaryKey());
5201 }
5202
5203 for (ModelListener<com.liferay.portal.model.Organization> listener : organizationListeners) {
5204 listener.onAfterRemoveAssociation(organization.getPrimaryKey(),
5205 User.class.getName(), userId);
5206 }
5207 }
5208 }
5209 }
5210
5211 private SqlUpdate _sqlUpdate;
5212 }
5213
5214 protected class RemoveOrganization {
5215 protected RemoveOrganization(UserPersistenceImpl persistenceImpl) {
5216 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
5217 "DELETE FROM Users_Orgs WHERE userId = ? AND organizationId = ?",
5218 new int[] { Types.BIGINT, Types.BIGINT });
5219 _persistenceImpl = persistenceImpl;
5220 }
5221
5222 protected void remove(long userId, long organizationId)
5223 throws SystemException {
5224 if (_persistenceImpl.containsOrganization.contains(userId,
5225 organizationId)) {
5226 ModelListener<com.liferay.portal.model.Organization>[] organizationListeners =
5227 organizationPersistence.getListeners();
5228
5229 for (ModelListener<User> listener : listeners) {
5230 listener.onBeforeRemoveAssociation(userId,
5231 com.liferay.portal.model.Organization.class.getName(),
5232 organizationId);
5233 }
5234
5235 for (ModelListener<com.liferay.portal.model.Organization> listener : organizationListeners) {
5236 listener.onBeforeRemoveAssociation(organizationId,
5237 User.class.getName(), userId);
5238 }
5239
5240 _sqlUpdate.update(new Object[] {
5241 new Long(userId), new Long(organizationId)
5242 });
5243
5244 for (ModelListener<User> listener : listeners) {
5245 listener.onAfterRemoveAssociation(userId,
5246 com.liferay.portal.model.Organization.class.getName(),
5247 organizationId);
5248 }
5249
5250 for (ModelListener<com.liferay.portal.model.Organization> listener : organizationListeners) {
5251 listener.onAfterRemoveAssociation(organizationId,
5252 User.class.getName(), userId);
5253 }
5254 }
5255 }
5256
5257 private SqlUpdate _sqlUpdate;
5258 private UserPersistenceImpl _persistenceImpl;
5259 }
5260
5261 protected class ContainsPermission {
5262 protected ContainsPermission(UserPersistenceImpl persistenceImpl) {
5263 super();
5264
5265 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
5266 _SQL_CONTAINSPERMISSION,
5267 new int[] { Types.BIGINT, Types.BIGINT }, RowMapper.COUNT);
5268 }
5269
5270 protected boolean contains(long userId, long permissionId) {
5271 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
5272 new Long(userId), new Long(permissionId)
5273 });
5274
5275 if (results.size() > 0) {
5276 Integer count = results.get(0);
5277
5278 if (count.intValue() > 0) {
5279 return true;
5280 }
5281 }
5282
5283 return false;
5284 }
5285
5286 private MappingSqlQuery _mappingSqlQuery;
5287 }
5288
5289 protected class AddPermission {
5290 protected AddPermission(UserPersistenceImpl persistenceImpl) {
5291 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
5292 "INSERT INTO Users_Permissions (userId, permissionId) VALUES (?, ?)",
5293 new int[] { Types.BIGINT, Types.BIGINT });
5294 _persistenceImpl = persistenceImpl;
5295 }
5296
5297 protected void add(long userId, long permissionId)
5298 throws SystemException {
5299 if (!_persistenceImpl.containsPermission.contains(userId,
5300 permissionId)) {
5301 ModelListener<com.liferay.portal.model.Permission>[] permissionListeners =
5302 permissionPersistence.getListeners();
5303
5304 for (ModelListener<User> listener : listeners) {
5305 listener.onBeforeAddAssociation(userId,
5306 com.liferay.portal.model.Permission.class.getName(),
5307 permissionId);
5308 }
5309
5310 for (ModelListener<com.liferay.portal.model.Permission> listener : permissionListeners) {
5311 listener.onBeforeAddAssociation(permissionId,
5312 User.class.getName(), userId);
5313 }
5314
5315 _sqlUpdate.update(new Object[] {
5316 new Long(userId), new Long(permissionId)
5317 });
5318
5319 for (ModelListener<User> listener : listeners) {
5320 listener.onAfterAddAssociation(userId,
5321 com.liferay.portal.model.Permission.class.getName(),
5322 permissionId);
5323 }
5324
5325 for (ModelListener<com.liferay.portal.model.Permission> listener : permissionListeners) {
5326 listener.onAfterAddAssociation(permissionId,
5327 User.class.getName(), userId);
5328 }
5329 }
5330 }
5331
5332 private SqlUpdate _sqlUpdate;
5333 private UserPersistenceImpl _persistenceImpl;
5334 }
5335
5336 protected class ClearPermissions {
5337 protected ClearPermissions(UserPersistenceImpl persistenceImpl) {
5338 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
5339 "DELETE FROM Users_Permissions WHERE userId = ?",
5340 new int[] { Types.BIGINT });
5341 }
5342
5343 protected void clear(long userId) throws SystemException {
5344 ModelListener<com.liferay.portal.model.Permission>[] permissionListeners =
5345 permissionPersistence.getListeners();
5346
5347 List<com.liferay.portal.model.Permission> permissions = null;
5348
5349 if ((listeners.length > 0) || (permissionListeners.length > 0)) {
5350 permissions = getPermissions(userId);
5351
5352 for (com.liferay.portal.model.Permission permission : permissions) {
5353 for (ModelListener<User> listener : listeners) {
5354 listener.onBeforeRemoveAssociation(userId,
5355 com.liferay.portal.model.Permission.class.getName(),
5356 permission.getPrimaryKey());
5357 }
5358
5359 for (ModelListener<com.liferay.portal.model.Permission> listener : permissionListeners) {
5360 listener.onBeforeRemoveAssociation(permission.getPrimaryKey(),
5361 User.class.getName(), userId);
5362 }
5363 }
5364 }
5365
5366 _sqlUpdate.update(new Object[] { new Long(userId) });
5367
5368 if ((listeners.length > 0) || (permissionListeners.length > 0)) {
5369 for (com.liferay.portal.model.Permission permission : permissions) {
5370 for (ModelListener<User> listener : listeners) {
5371 listener.onAfterRemoveAssociation(userId,
5372 com.liferay.portal.model.Permission.class.getName(),
5373 permission.getPrimaryKey());
5374 }
5375
5376 for (ModelListener<com.liferay.portal.model.Permission> listener : permissionListeners) {
5377 listener.onAfterRemoveAssociation(permission.getPrimaryKey(),
5378 User.class.getName(), userId);
5379 }
5380 }
5381 }
5382 }
5383
5384 private SqlUpdate _sqlUpdate;
5385 }
5386
5387 protected class RemovePermission {
5388 protected RemovePermission(UserPersistenceImpl persistenceImpl) {
5389 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
5390 "DELETE FROM Users_Permissions WHERE userId = ? AND permissionId = ?",
5391 new int[] { Types.BIGINT, Types.BIGINT });
5392 _persistenceImpl = persistenceImpl;
5393 }
5394
5395 protected void remove(long userId, long permissionId)
5396 throws SystemException {
5397 if (_persistenceImpl.containsPermission.contains(userId,
5398 permissionId)) {
5399 ModelListener<com.liferay.portal.model.Permission>[] permissionListeners =
5400 permissionPersistence.getListeners();
5401
5402 for (ModelListener<User> listener : listeners) {
5403 listener.onBeforeRemoveAssociation(userId,
5404 com.liferay.portal.model.Permission.class.getName(),
5405 permissionId);
5406 }
5407
5408 for (ModelListener<com.liferay.portal.model.Permission> listener : permissionListeners) {
5409 listener.onBeforeRemoveAssociation(permissionId,
5410 User.class.getName(), userId);
5411 }
5412
5413 _sqlUpdate.update(new Object[] {
5414 new Long(userId), new Long(permissionId)
5415 });
5416
5417 for (ModelListener<User> listener : listeners) {
5418 listener.onAfterRemoveAssociation(userId,
5419 com.liferay.portal.model.Permission.class.getName(),
5420 permissionId);
5421 }
5422
5423 for (ModelListener<com.liferay.portal.model.Permission> listener : permissionListeners) {
5424 listener.onAfterRemoveAssociation(permissionId,
5425 User.class.getName(), userId);
5426 }
5427 }
5428 }
5429
5430 private SqlUpdate _sqlUpdate;
5431 private UserPersistenceImpl _persistenceImpl;
5432 }
5433
5434 protected class ContainsRole {
5435 protected ContainsRole(UserPersistenceImpl persistenceImpl) {
5436 super();
5437
5438 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
5439 _SQL_CONTAINSROLE,
5440 new int[] { Types.BIGINT, Types.BIGINT }, RowMapper.COUNT);
5441 }
5442
5443 protected boolean contains(long userId, long roleId) {
5444 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
5445 new Long(userId), new Long(roleId)
5446 });
5447
5448 if (results.size() > 0) {
5449 Integer count = results.get(0);
5450
5451 if (count.intValue() > 0) {
5452 return true;
5453 }
5454 }
5455
5456 return false;
5457 }
5458
5459 private MappingSqlQuery _mappingSqlQuery;
5460 }
5461
5462 protected class AddRole {
5463 protected AddRole(UserPersistenceImpl persistenceImpl) {
5464 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
5465 "INSERT INTO Users_Roles (userId, roleId) VALUES (?, ?)",
5466 new int[] { Types.BIGINT, Types.BIGINT });
5467 _persistenceImpl = persistenceImpl;
5468 }
5469
5470 protected void add(long userId, long roleId) throws SystemException {
5471 if (!_persistenceImpl.containsRole.contains(userId, roleId)) {
5472 ModelListener<com.liferay.portal.model.Role>[] roleListeners = rolePersistence.getListeners();
5473
5474 for (ModelListener<User> listener : listeners) {
5475 listener.onBeforeAddAssociation(userId,
5476 com.liferay.portal.model.Role.class.getName(), roleId);
5477 }
5478
5479 for (ModelListener<com.liferay.portal.model.Role> listener : roleListeners) {
5480 listener.onBeforeAddAssociation(roleId,
5481 User.class.getName(), userId);
5482 }
5483
5484 _sqlUpdate.update(new Object[] {
5485 new Long(userId), new Long(roleId)
5486 });
5487
5488 for (ModelListener<User> listener : listeners) {
5489 listener.onAfterAddAssociation(userId,
5490 com.liferay.portal.model.Role.class.getName(), roleId);
5491 }
5492
5493 for (ModelListener<com.liferay.portal.model.Role> listener : roleListeners) {
5494 listener.onAfterAddAssociation(roleId,
5495 User.class.getName(), userId);
5496 }
5497 }
5498 }
5499
5500 private SqlUpdate _sqlUpdate;
5501 private UserPersistenceImpl _persistenceImpl;
5502 }
5503
5504 protected class ClearRoles {
5505 protected ClearRoles(UserPersistenceImpl persistenceImpl) {
5506 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
5507 "DELETE FROM Users_Roles WHERE userId = ?",
5508 new int[] { Types.BIGINT });
5509 }
5510
5511 protected void clear(long userId) throws SystemException {
5512 ModelListener<com.liferay.portal.model.Role>[] roleListeners = rolePersistence.getListeners();
5513
5514 List<com.liferay.portal.model.Role> roles = null;
5515
5516 if ((listeners.length > 0) || (roleListeners.length > 0)) {
5517 roles = getRoles(userId);
5518
5519 for (com.liferay.portal.model.Role role : roles) {
5520 for (ModelListener<User> listener : listeners) {
5521 listener.onBeforeRemoveAssociation(userId,
5522 com.liferay.portal.model.Role.class.getName(),
5523 role.getPrimaryKey());
5524 }
5525
5526 for (ModelListener<com.liferay.portal.model.Role> listener : roleListeners) {
5527 listener.onBeforeRemoveAssociation(role.getPrimaryKey(),
5528 User.class.getName(), userId);
5529 }
5530 }
5531 }
5532
5533 _sqlUpdate.update(new Object[] { new Long(userId) });
5534
5535 if ((listeners.length > 0) || (roleListeners.length > 0)) {
5536 for (com.liferay.portal.model.Role role : roles) {
5537 for (ModelListener<User> listener : listeners) {
5538 listener.onAfterRemoveAssociation(userId,
5539 com.liferay.portal.model.Role.class.getName(),
5540 role.getPrimaryKey());
5541 }
5542
5543 for (ModelListener<com.liferay.portal.model.Role> listener : roleListeners) {
5544 listener.onAfterRemoveAssociation(role.getPrimaryKey(),
5545 User.class.getName(), userId);
5546 }
5547 }
5548 }
5549 }
5550
5551 private SqlUpdate _sqlUpdate;
5552 }
5553
5554 protected class RemoveRole {
5555 protected RemoveRole(UserPersistenceImpl persistenceImpl) {
5556 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
5557 "DELETE FROM Users_Roles WHERE userId = ? AND roleId = ?",
5558 new int[] { Types.BIGINT, Types.BIGINT });
5559 _persistenceImpl = persistenceImpl;
5560 }
5561
5562 protected void remove(long userId, long roleId)
5563 throws SystemException {
5564 if (_persistenceImpl.containsRole.contains(userId, roleId)) {
5565 ModelListener<com.liferay.portal.model.Role>[] roleListeners = rolePersistence.getListeners();
5566
5567 for (ModelListener<User> listener : listeners) {
5568 listener.onBeforeRemoveAssociation(userId,
5569 com.liferay.portal.model.Role.class.getName(), roleId);
5570 }
5571
5572 for (ModelListener<com.liferay.portal.model.Role> listener : roleListeners) {
5573 listener.onBeforeRemoveAssociation(roleId,
5574 User.class.getName(), userId);
5575 }
5576
5577 _sqlUpdate.update(new Object[] {
5578 new Long(userId), new Long(roleId)
5579 });
5580
5581 for (ModelListener<User> listener : listeners) {
5582 listener.onAfterRemoveAssociation(userId,
5583 com.liferay.portal.model.Role.class.getName(), roleId);
5584 }
5585
5586 for (ModelListener<com.liferay.portal.model.Role> listener : roleListeners) {
5587 listener.onAfterRemoveAssociation(roleId,
5588 User.class.getName(), userId);
5589 }
5590 }
5591 }
5592
5593 private SqlUpdate _sqlUpdate;
5594 private UserPersistenceImpl _persistenceImpl;
5595 }
5596
5597 protected class ContainsUserGroup {
5598 protected ContainsUserGroup(UserPersistenceImpl persistenceImpl) {
5599 super();
5600
5601 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
5602 _SQL_CONTAINSUSERGROUP,
5603 new int[] { Types.BIGINT, Types.BIGINT }, RowMapper.COUNT);
5604 }
5605
5606 protected boolean contains(long userId, long userGroupId) {
5607 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
5608 new Long(userId), new Long(userGroupId)
5609 });
5610
5611 if (results.size() > 0) {
5612 Integer count = results.get(0);
5613
5614 if (count.intValue() > 0) {
5615 return true;
5616 }
5617 }
5618
5619 return false;
5620 }
5621
5622 private MappingSqlQuery _mappingSqlQuery;
5623 }
5624
5625 protected class AddUserGroup {
5626 protected AddUserGroup(UserPersistenceImpl persistenceImpl) {
5627 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
5628 "INSERT INTO Users_UserGroups (userId, userGroupId) VALUES (?, ?)",
5629 new int[] { Types.BIGINT, Types.BIGINT });
5630 _persistenceImpl = persistenceImpl;
5631 }
5632
5633 protected void add(long userId, long userGroupId)
5634 throws SystemException {
5635 if (!_persistenceImpl.containsUserGroup.contains(userId, userGroupId)) {
5636 ModelListener<com.liferay.portal.model.UserGroup>[] userGroupListeners =
5637 userGroupPersistence.getListeners();
5638
5639 for (ModelListener<User> listener : listeners) {
5640 listener.onBeforeAddAssociation(userId,
5641 com.liferay.portal.model.UserGroup.class.getName(),
5642 userGroupId);
5643 }
5644
5645 for (ModelListener<com.liferay.portal.model.UserGroup> listener : userGroupListeners) {
5646 listener.onBeforeAddAssociation(userGroupId,
5647 User.class.getName(), userId);
5648 }
5649
5650 _sqlUpdate.update(new Object[] {
5651 new Long(userId), new Long(userGroupId)
5652 });
5653
5654 for (ModelListener<User> listener : listeners) {
5655 listener.onAfterAddAssociation(userId,
5656 com.liferay.portal.model.UserGroup.class.getName(),
5657 userGroupId);
5658 }
5659
5660 for (ModelListener<com.liferay.portal.model.UserGroup> listener : userGroupListeners) {
5661 listener.onAfterAddAssociation(userGroupId,
5662 User.class.getName(), userId);
5663 }
5664 }
5665 }
5666
5667 private SqlUpdate _sqlUpdate;
5668 private UserPersistenceImpl _persistenceImpl;
5669 }
5670
5671 protected class ClearUserGroups {
5672 protected ClearUserGroups(UserPersistenceImpl persistenceImpl) {
5673 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
5674 "DELETE FROM Users_UserGroups WHERE userId = ?",
5675 new int[] { Types.BIGINT });
5676 }
5677
5678 protected void clear(long userId) throws SystemException {
5679 ModelListener<com.liferay.portal.model.UserGroup>[] userGroupListeners =
5680 userGroupPersistence.getListeners();
5681
5682 List<com.liferay.portal.model.UserGroup> userGroups = null;
5683
5684 if ((listeners.length > 0) || (userGroupListeners.length > 0)) {
5685 userGroups = getUserGroups(userId);
5686
5687 for (com.liferay.portal.model.UserGroup userGroup : userGroups) {
5688 for (ModelListener<User> listener : listeners) {
5689 listener.onBeforeRemoveAssociation(userId,
5690 com.liferay.portal.model.UserGroup.class.getName(),
5691 userGroup.getPrimaryKey());
5692 }
5693
5694 for (ModelListener<com.liferay.portal.model.UserGroup> listener : userGroupListeners) {
5695 listener.onBeforeRemoveAssociation(userGroup.getPrimaryKey(),
5696 User.class.getName(), userId);
5697 }
5698 }
5699 }
5700
5701 _sqlUpdate.update(new Object[] { new Long(userId) });
5702
5703 if ((listeners.length > 0) || (userGroupListeners.length > 0)) {
5704 for (com.liferay.portal.model.UserGroup userGroup : userGroups) {
5705 for (ModelListener<User> listener : listeners) {
5706 listener.onAfterRemoveAssociation(userId,
5707 com.liferay.portal.model.UserGroup.class.getName(),
5708 userGroup.getPrimaryKey());
5709 }
5710
5711 for (ModelListener<com.liferay.portal.model.UserGroup> listener : userGroupListeners) {
5712 listener.onAfterRemoveAssociation(userGroup.getPrimaryKey(),
5713 User.class.getName(), userId);
5714 }
5715 }
5716 }
5717 }
5718
5719 private SqlUpdate _sqlUpdate;
5720 }
5721
5722 protected class RemoveUserGroup {
5723 protected RemoveUserGroup(UserPersistenceImpl persistenceImpl) {
5724 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
5725 "DELETE FROM Users_UserGroups WHERE userId = ? AND userGroupId = ?",
5726 new int[] { Types.BIGINT, Types.BIGINT });
5727 _persistenceImpl = persistenceImpl;
5728 }
5729
5730 protected void remove(long userId, long userGroupId)
5731 throws SystemException {
5732 if (_persistenceImpl.containsUserGroup.contains(userId, userGroupId)) {
5733 ModelListener<com.liferay.portal.model.UserGroup>[] userGroupListeners =
5734 userGroupPersistence.getListeners();
5735
5736 for (ModelListener<User> listener : listeners) {
5737 listener.onBeforeRemoveAssociation(userId,
5738 com.liferay.portal.model.UserGroup.class.getName(),
5739 userGroupId);
5740 }
5741
5742 for (ModelListener<com.liferay.portal.model.UserGroup> listener : userGroupListeners) {
5743 listener.onBeforeRemoveAssociation(userGroupId,
5744 User.class.getName(), userId);
5745 }
5746
5747 _sqlUpdate.update(new Object[] {
5748 new Long(userId), new Long(userGroupId)
5749 });
5750
5751 for (ModelListener<User> listener : listeners) {
5752 listener.onAfterRemoveAssociation(userId,
5753 com.liferay.portal.model.UserGroup.class.getName(),
5754 userGroupId);
5755 }
5756
5757 for (ModelListener<com.liferay.portal.model.UserGroup> listener : userGroupListeners) {
5758 listener.onAfterRemoveAssociation(userGroupId,
5759 User.class.getName(), userId);
5760 }
5761 }
5762 }
5763
5764 private SqlUpdate _sqlUpdate;
5765 private UserPersistenceImpl _persistenceImpl;
5766 }
5767
5768 private static final String _SQL_GETGROUPS = "SELECT {Group_.*} FROM Group_ INNER JOIN Users_Groups ON (Users_Groups.groupId = Group_.groupId) WHERE (Users_Groups.userId = ?)";
5769 private static final String _SQL_GETGROUPSSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM Users_Groups WHERE userId = ?";
5770 private static final String _SQL_CONTAINSGROUP = "SELECT COUNT(*) AS COUNT_VALUE FROM Users_Groups WHERE userId = ? AND groupId = ?";
5771 private static final String _SQL_GETORGANIZATIONS = "SELECT {Organization_.*} FROM Organization_ INNER JOIN Users_Orgs ON (Users_Orgs.organizationId = Organization_.organizationId) WHERE (Users_Orgs.userId = ?)";
5772 private static final String _SQL_GETORGANIZATIONSSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM Users_Orgs WHERE userId = ?";
5773 private static final String _SQL_CONTAINSORGANIZATION = "SELECT COUNT(*) AS COUNT_VALUE FROM Users_Orgs WHERE userId = ? AND organizationId = ?";
5774 private static final String _SQL_GETPERMISSIONS = "SELECT {Permission_.*} FROM Permission_ INNER JOIN Users_Permissions ON (Users_Permissions.permissionId = Permission_.permissionId) WHERE (Users_Permissions.userId = ?)";
5775 private static final String _SQL_GETPERMISSIONSSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM Users_Permissions WHERE userId = ?";
5776 private static final String _SQL_CONTAINSPERMISSION = "SELECT COUNT(*) AS COUNT_VALUE FROM Users_Permissions WHERE userId = ? AND permissionId = ?";
5777 private static final String _SQL_GETROLES = "SELECT {Role_.*} FROM Role_ INNER JOIN Users_Roles ON (Users_Roles.roleId = Role_.roleId) WHERE (Users_Roles.userId = ?)";
5778 private static final String _SQL_GETROLESSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM Users_Roles WHERE userId = ?";
5779 private static final String _SQL_CONTAINSROLE = "SELECT COUNT(*) AS COUNT_VALUE FROM Users_Roles WHERE userId = ? AND roleId = ?";
5780 private static final String _SQL_GETUSERGROUPS = "SELECT {UserGroup.*} FROM UserGroup INNER JOIN Users_UserGroups ON (Users_UserGroups.userGroupId = UserGroup.userGroupId) WHERE (Users_UserGroups.userId = ?)";
5781 private static final String _SQL_GETUSERGROUPSSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM Users_UserGroups WHERE userId = ?";
5782 private static final String _SQL_CONTAINSUSERGROUP = "SELECT COUNT(*) AS COUNT_VALUE FROM Users_UserGroups WHERE userId = ? AND userGroupId = ?";
5783 private static Log _log = LogFactoryUtil.getLog(UserPersistenceImpl.class);
5784}