Source Code Cross Referenced for UserImpl.java in  » Portal » liferay-portal-4.4.2 » com » liferay » portal » model » impl » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Portal » liferay portal 4.4.2 » com.liferay.portal.model.impl 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * Copyright (c) 2000-2008 Liferay, Inc. All rights reserved.
003:         *
004:         * Permission is hereby granted, free of charge, to any person obtaining a copy
005:         * of this software and associated documentation files (the "Software"), to deal
006:         * in the Software without restriction, including without limitation the rights
007:         * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
008:         * copies of the Software, and to permit persons to whom the Software is
009:         * furnished to do so, subject to the following conditions:
010:         *
011:         * The above copyright notice and this permission notice shall be included in
012:         * all copies or substantial portions of the Software.
013:         *
014:         * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
015:         * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
016:         * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
017:         * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
018:         * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
019:         * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
020:         * SOFTWARE.
021:         */package com.liferay.portal.model.impl;
022:
023:        import com.liferay.portal.PortalException;
024:        import com.liferay.portal.SystemException;
025:        import com.liferay.portal.kernel.util.LocaleUtil;
026:        import com.liferay.portal.kernel.util.StringPool;
027:        import com.liferay.portal.kernel.util.TimeZoneUtil;
028:        import com.liferay.portal.kernel.util.Validator;
029:        import com.liferay.portal.model.Company;
030:        import com.liferay.portal.model.Contact;
031:        import com.liferay.portal.model.Group;
032:        import com.liferay.portal.model.Organization;
033:        import com.liferay.portal.model.PasswordPolicy;
034:        import com.liferay.portal.model.User;
035:        import com.liferay.portal.service.CompanyLocalServiceUtil;
036:        import com.liferay.portal.service.ContactLocalServiceUtil;
037:        import com.liferay.portal.service.GroupLocalServiceUtil;
038:        import com.liferay.portal.service.OrganizationLocalServiceUtil;
039:        import com.liferay.portal.service.PasswordPolicyLocalServiceUtil;
040:        import com.liferay.portal.service.RoleLocalServiceUtil;
041:        import com.liferay.portal.util.PortalUtil;
042:        import com.liferay.portal.util.comparator.OrganizationNameComparator;
043:        import com.liferay.util.dao.hibernate.QueryUtil;
044:
045:        import java.util.ArrayList;
046:        import java.util.Collections;
047:        import java.util.Date;
048:        import java.util.Iterator;
049:        import java.util.LinkedHashMap;
050:        import java.util.List;
051:        import java.util.Locale;
052:        import java.util.TimeZone;
053:
054:        import org.apache.commons.logging.Log;
055:        import org.apache.commons.logging.LogFactory;
056:
057:        /**
058:         * <a href="UserImpl.java.html"><b><i>View Source</i></b></a>
059:         *
060:         * @author Brian Wing Shun Chan
061:         *
062:         */
063:        public class UserImpl extends UserModelImpl implements  User {
064:
065:            public static String getFullName(String firstName,
066:                    String middleName, String lastName) {
067:
068:                return ContactImpl.getFullName(firstName, middleName, lastName);
069:            }
070:
071:            public UserImpl() {
072:            }
073:
074:            public String getCompanyMx() {
075:                String companyMx = null;
076:
077:                try {
078:                    Company company = CompanyLocalServiceUtil
079:                            .getCompanyById(getCompanyId());
080:
081:                    companyMx = company.getMx();
082:                } catch (Exception e) {
083:                    _log.error(e);
084:                }
085:
086:                return companyMx;
087:            }
088:
089:            public boolean hasCompanyMx() {
090:                return hasCompanyMx(getEmailAddress());
091:            }
092:
093:            public boolean hasCompanyMx(String emailAddress) {
094:                try {
095:                    Company company = CompanyLocalServiceUtil
096:                            .getCompanyById(getCompanyId());
097:
098:                    return company.hasCompanyMx(emailAddress);
099:                } catch (Exception e) {
100:                    _log.error(e);
101:                }
102:
103:                return false;
104:            }
105:
106:            public String getLogin() throws PortalException, SystemException {
107:                String login = null;
108:
109:                Company company = CompanyLocalServiceUtil
110:                        .getCompanyById(getCompanyId());
111:
112:                if (company.getAuthType().equals(CompanyImpl.AUTH_TYPE_EA)) {
113:                    login = getEmailAddress();
114:                } else if (company.getAuthType().equals(
115:                        CompanyImpl.AUTH_TYPE_SN)) {
116:                    login = getScreenName();
117:                } else if (company.getAuthType().equals(
118:                        CompanyImpl.AUTH_TYPE_ID)) {
119:                    login = String.valueOf(getUserId());
120:                }
121:
122:                return login;
123:            }
124:
125:            public PasswordPolicy getPasswordPolicy() throws PortalException,
126:                    SystemException {
127:
128:                PasswordPolicy passwordPolicy = PasswordPolicyLocalServiceUtil
129:                        .getPasswordPolicyByUserId(getUserId());
130:
131:                return passwordPolicy;
132:            }
133:
134:            public String getPasswordUnencrypted() {
135:                return _passwordUnencrypted;
136:            }
137:
138:            public void setPasswordUnencrypted(String passwordUnencrypted) {
139:                _passwordUnencrypted = passwordUnencrypted;
140:            }
141:
142:            public boolean getPasswordModified() {
143:                return _passwordModified;
144:            }
145:
146:            public boolean isPasswordModified() {
147:                return _passwordModified;
148:            }
149:
150:            public void setPasswordModified(boolean passwordModified) {
151:                _passwordModified = passwordModified;
152:            }
153:
154:            public Locale getLocale() {
155:                return _locale;
156:            }
157:
158:            public void setLanguageId(String languageId) {
159:                _locale = LocaleUtil.fromLanguageId(languageId);
160:
161:                super .setLanguageId(LocaleUtil.toLanguageId(_locale));
162:            }
163:
164:            public TimeZone getTimeZone() {
165:                return _timeZone;
166:            }
167:
168:            public void setTimeZoneId(String timeZoneId) {
169:                if (Validator.isNull(timeZoneId)) {
170:                    timeZoneId = TimeZoneUtil.getDefault().getID();
171:                }
172:
173:                _timeZone = TimeZone.getTimeZone(timeZoneId);
174:
175:                super .setTimeZoneId(timeZoneId);
176:            }
177:
178:            public Contact getContact() {
179:                Contact contact = null;
180:
181:                try {
182:                    contact = ContactLocalServiceUtil
183:                            .getContact(getContactId());
184:                } catch (Exception e) {
185:                    contact = new ContactImpl();
186:
187:                    _log.error(e);
188:                }
189:
190:                return contact;
191:            }
192:
193:            public String getFirstName() {
194:                return getContact().getFirstName();
195:            }
196:
197:            public String getMiddleName() {
198:                return getContact().getMiddleName();
199:            }
200:
201:            public String getLastName() {
202:                return getContact().getLastName();
203:            }
204:
205:            public String getFullName() {
206:                return getContact().getFullName();
207:            }
208:
209:            public boolean getMale() {
210:                return getContact().getMale();
211:            }
212:
213:            public boolean isMale() {
214:                return getMale();
215:            }
216:
217:            public boolean getFemale() {
218:                return !getMale();
219:            }
220:
221:            public boolean isFemale() {
222:                return getFemale();
223:            }
224:
225:            public Date getBirthday() {
226:                return getContact().getBirthday();
227:            }
228:
229:            public Group getGroup() {
230:                Group group = null;
231:
232:                try {
233:                    group = GroupLocalServiceUtil.getUserGroup(getCompanyId(),
234:                            getUserId());
235:                } catch (Exception e) {
236:                }
237:
238:                return group;
239:            }
240:
241:            /**
242:             * @deprecated Will return the first regular organization of the list in
243:             * alphabetical order.
244:             */
245:            public Organization getOrganization() {
246:                try {
247:                    List organizations = OrganizationLocalServiceUtil
248:                            .getUserOrganizations(getUserId());
249:
250:                    Collections.sort(organizations,
251:                            new OrganizationNameComparator(true));
252:
253:                    for (int i = 0; i < organizations.size(); i++) {
254:                        Organization organization = (Organization) organizations
255:                                .get(i);
256:
257:                        if (!organization.isLocation()) {
258:                            return organization;
259:                        }
260:                    }
261:                } catch (Exception e) {
262:                    if (_log.isWarnEnabled()) {
263:                        _log.warn("Unable to get an organization for user "
264:                                + getUserId());
265:                    }
266:                }
267:
268:                return new OrganizationImpl();
269:            }
270:
271:            public long[] getOrganizationIds() {
272:                List organizations = getOrganizations();
273:
274:                long[] organizationIds = new long[organizations.size()];
275:
276:                Iterator itr = organizations.iterator();
277:
278:                for (int i = 0; itr.hasNext(); i++) {
279:                    Organization organization = (Organization) itr.next();
280:
281:                    organizationIds[i] = organization.getOrganizationId();
282:                }
283:
284:                return organizationIds;
285:            }
286:
287:            public List getOrganizations() {
288:                try {
289:                    return OrganizationLocalServiceUtil
290:                            .getUserOrganizations(getUserId());
291:                } catch (Exception e) {
292:                    if (_log.isWarnEnabled()) {
293:                        _log.warn("Unable to get organizations for user "
294:                                + getUserId());
295:                    }
296:                }
297:
298:                return new ArrayList();
299:            }
300:
301:            public boolean hasOrganization() {
302:                if (getOrganizations().size() > 0) {
303:                    return true;
304:                } else {
305:                    return false;
306:                }
307:            }
308:
309:            /**
310:             * @deprecated
311:             */
312:            public Organization getLocation() {
313:                try {
314:                    List organizations = OrganizationLocalServiceUtil
315:                            .getUserOrganizations(getUserId());
316:
317:                    for (int i = 0; i < organizations.size(); i++) {
318:                        Organization organization = (Organization) organizations
319:                                .get(i);
320:
321:                        if (organization.isLocation()) {
322:                            return organization;
323:                        }
324:                    }
325:                } catch (Exception e) {
326:                    if (_log.isWarnEnabled()) {
327:                        _log.warn("Unable to get a location for user "
328:                                + getUserId());
329:                    }
330:                }
331:
332:                return new OrganizationImpl();
333:            }
334:
335:            /**
336:             * @deprecated
337:             */
338:            public long getLocationId() {
339:                Organization location = getLocation();
340:
341:                if (location == null) {
342:                    return OrganizationImpl.DEFAULT_PARENT_ORGANIZATION_ID;
343:                }
344:
345:                return location.getOrganizationId();
346:            }
347:
348:            /**
349:             * @deprecated
350:             */
351:            public boolean hasLocation() {
352:                if (getLocation().getOrganizationId() > 0) {
353:                    return true;
354:                } else {
355:                    return false;
356:                }
357:            }
358:
359:            public int getPrivateLayoutsPageCount() {
360:                try {
361:                    Group group = getGroup();
362:
363:                    if (group == null) {
364:                        return 0;
365:                    } else {
366:                        return group.getPrivateLayoutsPageCount();
367:                    }
368:                } catch (Exception e) {
369:                    _log.error(e);
370:                }
371:
372:                return 0;
373:            }
374:
375:            public boolean hasPrivateLayouts() {
376:                if (getPrivateLayoutsPageCount() > 0) {
377:                    return true;
378:                } else {
379:                    return false;
380:                }
381:            }
382:
383:            public int getPublicLayoutsPageCount() {
384:                try {
385:                    Group group = getGroup();
386:
387:                    if (group == null) {
388:                        return 0;
389:                    } else {
390:                        return group.getPublicLayoutsPageCount();
391:                    }
392:                } catch (Exception e) {
393:                    _log.error(e);
394:                }
395:
396:                return 0;
397:            }
398:
399:            public boolean hasPublicLayouts() {
400:                if (getPublicLayoutsPageCount() > 0) {
401:                    return true;
402:                } else {
403:                    return false;
404:                }
405:            }
406:
407:            public boolean isLayoutsRequired() {
408:                try {
409:                    return RoleLocalServiceUtil.hasUserRole(getUserId(),
410:                            getCompanyId(), RoleImpl.POWER_USER, true);
411:                } catch (Exception e) {
412:                    return false;
413:                }
414:            }
415:
416:            public List getMyPlaces() {
417:                List myPlaces = new ArrayList();
418:
419:                try {
420:                    if (isDefaultUser()) {
421:                        return myPlaces;
422:                    }
423:
424:                    LinkedHashMap groupParams = new LinkedHashMap();
425:
426:                    groupParams.put("usersGroups", new Long(getUserId()));
427:                    //groupParams.put("pageCount", StringPool.BLANK);
428:
429:                    myPlaces = GroupLocalServiceUtil.search(getCompanyId(),
430:                            null, null, groupParams, QueryUtil.ALL_POS,
431:                            QueryUtil.ALL_POS);
432:
433:                    List userOrgs = getOrganizations();
434:
435:                    Iterator itr = userOrgs.iterator();
436:
437:                    while (itr.hasNext()) {
438:                        Organization organization = (Organization) itr.next();
439:
440:                        myPlaces.add(0, organization.getGroup());
441:                    }
442:
443:                    if (isLayoutsRequired()) {
444:                        Group userGroup = getGroup();
445:
446:                        myPlaces.add(0, userGroup);
447:                    }
448:                } catch (Exception e) {
449:                    if (_log.isWarnEnabled()) {
450:                        _log.warn(e, e);
451:                    }
452:                }
453:
454:                return myPlaces;
455:            }
456:
457:            public boolean hasMyPlaces() {
458:                try {
459:                    if (isDefaultUser()) {
460:                        return false;
461:                    }
462:
463:                    LinkedHashMap groupParams = new LinkedHashMap();
464:
465:                    groupParams.put("usersGroups", new Long(getUserId()));
466:                    //groupParams.put("pageCount", StringPool.BLANK);
467:
468:                    int count = GroupLocalServiceUtil.searchCount(
469:                            getCompanyId(), null, null, groupParams);
470:
471:                    if (count > 0) {
472:                        return true;
473:                    }
474:
475:                    count = OrganizationLocalServiceUtil
476:                            .getUserOrganizationsCount(getUserId());
477:
478:                    if (count > 0) {
479:                        return true;
480:                    }
481:
482:                    if (isLayoutsRequired()) {
483:                        return true;
484:                    }
485:                } catch (Exception e) {
486:                    if (_log.isWarnEnabled()) {
487:                        _log.warn(e, e);
488:                    }
489:                }
490:
491:                return false;
492:            }
493:
494:            public String getDisplayURL(String portalURL) {
495:                try {
496:                    Group group = getGroup();
497:
498:                    int publicLayoutsPageCount = group
499:                            .getPublicLayoutsPageCount();
500:
501:                    if (publicLayoutsPageCount > 0) {
502:                        return portalURL + PortalUtil.getPathMain()
503:                                + "/my_places/view?groupId="
504:                                + group.getGroupId() + "&privateLayout=0";
505:                    }
506:                } catch (Exception e) {
507:                    _log.error(e);
508:                }
509:
510:                return StringPool.BLANK;
511:            }
512:
513:            private static Log _log = LogFactory.getLog(UserImpl.class);
514:
515:            private boolean _passwordModified;
516:            private String _passwordUnencrypted;
517:            private Locale _locale;
518:            private TimeZone _timeZone;
519:
520:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.