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