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.portlet;
022:
023: import com.liferay.portal.PortalException;
024: import com.liferay.portal.SystemException;
025: import com.liferay.portal.kernel.util.StringPool;
026: import com.liferay.portal.model.Address;
027: import com.liferay.portal.model.User;
028:
029: /**
030: * <a href="UserAttributes.java.html"><b><i>View Source</i></b></a>
031: *
032: * @author Brian Wing Shun Chan
033: *
034: */
035: public class UserAttributes {
036:
037: // Mandatory Liferay attributes
038:
039: public static final String LIFERAY_COMPANY_ID = "liferay.company.id";
040:
041: public static final String LIFERAY_USER_ID = "liferay.user.id";
042:
043: public static final String USER_NAME_FULL = "user.name.full";
044:
045: // See page 119 of the JSR 168 spec
046:
047: public static final String USER_BDATE = "user.bdate";
048:
049: public static final String USER_GENDER = "user.gender";
050:
051: public static final String USER_EMPLOYER = "user.employer";
052:
053: public static final String USER_DEPARTMENT = "user.department";
054:
055: public static final String USER_JOBTITLE = "user.jobtitle";
056:
057: public static final String USER_NAME_PREFIX = "user.name.prefix";
058:
059: public static final String USER_NAME_GIVEN = "user.name.given";
060:
061: public static final String USER_NAME_FAMILY = "user.name.family";
062:
063: public static final String USER_NAME_MIDDLE = "user.name.middle";
064:
065: public static final String USER_NAME_SUFFIX = "user.name.suffix";
066:
067: public static final String USER_NAME_NICKNAME = "user.name.nickName";
068:
069: public static final String USER_HOME_INFO_POSTAL_NAME = "user.home-info.postal.name";
070:
071: public static final String USER_HOME_INFO_POSTAL_STREET = "user.home-info.postal.street";
072:
073: public static final String USER_HOME_INFO_POSTAL_CITY = "user.home-info.postal.city";
074:
075: public static final String USER_HOME_INFO_POSTAL_STATEPROV = "user.home-info.postal.stateprov";
076:
077: public static final String USER_HOME_INFO_POSTAL_POSTALCODE = "user.home-info.postal.postalcode";
078:
079: public static final String USER_HOME_INFO_POSTAL_COUNTRY = "user.home-info.postal.country";
080:
081: public static final String USER_HOME_INFO_POSTAL_ORGANIZATION = "user.home-info.postal.organization";
082:
083: public static final String USER_HOME_INFO_TELECOM_TELEPHONE_INTCODE = "user.home-info.telecom.telephone.intcode";
084:
085: public static final String USER_HOME_INFO_TELECOM_TELEPHONE_LOCCODE = "user.home-info.telecom.telephone.loccode";
086:
087: public static final String USER_HOME_INFO_TELECOM_TELEPHONE_NUMBER = "user.home-info.telecom.telephone.number";
088:
089: public static final String USER_HOME_INFO_TELECOM_TELEPHONE_EXT = "user.home-info.telecom.telephone.ext";
090:
091: public static final String USER_HOME_INFO_TELECOM_TELEPHONE_COMMENT = "user.home-info.telecom.telephone.comment";
092:
093: public static final String USER_HOME_INFO_TELECOM_FAX_INTCODE = "user.home-info.telecom.fax.intcode";
094:
095: public static final String USER_HOME_INFO_TELECOM_FAX_LOCCODE = "user.home-info.telecom.fax.loccode";
096:
097: public static final String USER_HOME_INFO_TELECOM_FAX_NUMBER = "user.home-info.telecom.fax.number";
098:
099: public static final String USER_HOME_INFO_TELECOM_FAX_EXT = "user.home-info.telecom.fax.ext";
100:
101: public static final String USER_HOME_INFO_TELECOM_FAX_COMMENT = "user.home-info.telecom.fax.comment";
102:
103: public static final String USER_HOME_INFO_TELECOM_MOBILE_INTCODE = "user.home-info.telecom.mobile.intcode";
104:
105: public static final String USER_HOME_INFO_TELECOM_MOBILE_LOCCODE = "user.home-info.telecom.mobile.loccode";
106:
107: public static final String USER_HOME_INFO_TELECOM_MOBILE_NUMBER = "user.home-info.telecom.mobile.number";
108:
109: public static final String USER_HOME_INFO_TELECOM_MOBILE_EXT = "user.home-info.telecom.mobile.ext";
110:
111: public static final String USER_HOME_INFO_TELECOM_MOBILE_COMMENT = "user.home-info.telecom.mobile.comment";
112:
113: public static final String USER_HOME_INFO_TELECOM_PAGER_INTCODE = "user.home-info.telecom.pager.intcode";
114:
115: public static final String USER_HOME_INFO_TELECOM_PAGER_LOCCODE = "user.home-info.telecom.pager.loccode";
116:
117: public static final String USER_HOME_INFO_TELECOM_PAGER_NUMBER = "user.home-info.telecom.pager.number";
118:
119: public static final String USER_HOME_INFO_TELECOM_PAGER_EXT = "user.home-info.telecom.pager.ext";
120:
121: public static final String USER_HOME_INFO_TELECOM_PAGER_COMMENT = "user.home-info.telecom.pager.comment";
122:
123: public static final String USER_HOME_INFO_ONLINE_EMAIL = "user.home-info.online.email";
124:
125: public static final String USER_HOME_INFO_ONLINE_URI = "user.home-info.online.uri";
126:
127: public static final String USER_BUSINESS_INFO_POSTAL_NAME = "user.business-info.postal.name";
128:
129: public static final String USER_BUSINESS_INFO_POSTAL_STREET = "user.business-info.postal.street";
130:
131: public static final String USER_BUSINESS_INFO_POSTAL_CITY = "user.business-info.postal.city";
132:
133: public static final String USER_BUSINESS_INFO_POSTAL_STATEPROV = "user.business-info.postal.stateprov";
134:
135: public static final String USER_BUSINESS_INFO_POSTAL_POSTALCODE = "user.business-info.postal.postalcode";
136:
137: public static final String USER_BUSINESS_INFO_POSTAL_COUNTRY = "user.business-info.postal.country";
138:
139: public static final String USER_BUSINESS_INFO_POSTAL_ORGANIZATION = "user.business-info.postal.organization";
140:
141: public static final String USER_BUSINESS_INFO_TELECOM_TELEPHONE_INTCODE = "user.business-info.telecom.telephone.intcode";
142:
143: public static final String USER_BUSINESS_INFO_TELECOM_TELEPHONE_LOCCODE = "user.business-info.telecom.telephone.loccode";
144:
145: public static final String USER_BUSINESS_INFO_TELECOM_TELEPHONE_NUMBER = "user.business-info.telecom.telephone.number";
146:
147: public static final String USER_BUSINESS_INFO_TELECOM_TELEPHONE_EXT = "user.business-info.telecom.telephone.ext";
148:
149: public static final String USER_BUSINESS_INFO_TELECOM_TELEPHONE_COMMENT = "user.business-info.telecom.telephone.comment";
150:
151: public static final String USER_BUSINESS_INFO_TELECOM_FAX_INTCODE = "user.business-info.telecom.fax.intcode";
152:
153: public static final String USER_BUSINESS_INFO_TELECOM_FAX_LOCCODE = "user.business-info.telecom.fax.loccode";
154:
155: public static final String USER_BUSINESS_INFO_TELECOM_FAX_NUMBER = "user.business-info.telecom.fax.number";
156:
157: public static final String USER_BUSINESS_INFO_TELECOM_FAX_EXT = "user.business-info.telecom.fax.ext";
158:
159: public static final String USER_BUSINESS_INFO_TELECOM_FAX_COMMENT = "user.business-info.telecom.fax.comment";
160:
161: public static final String USER_BUSINESS_INFO_TELECOM_MOBILE_INTCODE = "user.business-info.telecom.mobile.intcode";
162:
163: public static final String USER_BUSINESS_INFO_TELECOM_MOBILE_LOCCODE = "user.business-info.telecom.mobile.loccode";
164:
165: public static final String USER_BUSINESS_INFO_TELECOM_MOBILE_NUMBER = "user.business-info.telecom.mobile.number";
166:
167: public static final String USER_BUSINESS_INFO_TELECOM_MOBILE_EXT = "user.business-info.telecom.mobile.ext";
168:
169: public static final String USER_BUSINESS_INFO_TELECOM_MOBILE_COMMENT = "user.business-info.telecom.mobile.comment";
170:
171: public static final String USER_BUSINESS_INFO_TELECOM_PAGER_INTCODE = "user.business-info.telecom.pager.intcode";
172:
173: public static final String USER_BUSINESS_INFO_TELECOM_PAGER_LOCCODE = "user.business-info.telecom.pager.loccode";
174:
175: public static final String USER_BUSINESS_INFO_TELECOM_PAGER_NUMBER = "user.business-info.telecom.pager.number";
176:
177: public static final String USER_BUSINESS_INFO_TELECOM_PAGER_EXT = "user.business-info.telecom.pager.ext";
178:
179: public static final String USER_BUSINESS_INFO_TELECOM_PAGER_COMMENT = "user.business-info.telecom.pager.comment";
180:
181: public static final String USER_BUSINESS_INFO_ONLINE_EMAIL = "user.business-info.online.email";
182:
183: public static final String USER_BUSINESS_INFO_ONLINE_URI = "user.business-info.online.uri";
184:
185: public UserAttributes(User user) throws PortalException,
186: SystemException {
187: _user = user;
188:
189: /*List addresses = user.getAddresses();
190:
191: for (int i = 0; i < addresses.size(); i++) {
192: Address address = (Address)addresses.get(i);
193:
194: if (address.getDescription().equalsIgnoreCase("home")) {
195: _homeAddress = address;
196: }
197: else if (address.getDescription().equalsIgnoreCase("business")) {
198: _bizAddress = address;
199: }
200: }*/
201: }
202:
203: public String getValue(String name) {
204: if (name == null) {
205: return null;
206: }
207:
208: if (name.equals(LIFERAY_COMPANY_ID)) {
209: return String.valueOf(_user.getCompanyId());
210: } else if (name.equals(LIFERAY_USER_ID)) {
211: return String.valueOf(_user.getUserId());
212: } else if (name.equals(USER_NAME_FULL)) {
213: return _user.getFullName();
214: } else if (name.equals(USER_BDATE)) {
215: return _user.getBirthday().toString();
216: } else if (name.equals(USER_GENDER)) {
217: return _user.isMale() ? "male" : "female";
218: } else if (name.equals(USER_EMPLOYER)) {
219: return StringPool.BLANK;
220: } else if (name.equals(USER_DEPARTMENT)) {
221: return StringPool.BLANK;
222: } else if (name.equals(USER_JOBTITLE)) {
223: return StringPool.BLANK;
224: } else if (name.equals(USER_NAME_PREFIX)) {
225: return StringPool.BLANK;
226: } else if (name.equals(USER_NAME_GIVEN)) {
227: return _user.getFirstName();
228: } else if (name.equals(USER_NAME_FAMILY)) {
229: return _user.getLastName();
230: } else if (name.equals(USER_NAME_MIDDLE)) {
231: return _user.getMiddleName();
232: } else if (name.equals(USER_NAME_SUFFIX)) {
233: return StringPool.BLANK;
234: } else if (name.equals(USER_NAME_NICKNAME)) {
235: return _user.getScreenName();
236: } else if (name.equals(USER_HOME_INFO_POSTAL_NAME)) {
237: return StringPool.BLANK;
238: } else if (name.equals(USER_HOME_INFO_POSTAL_STREET)) {
239: if (_homeAddress != null) {
240: return _homeAddress.getStreet1();
241: } else {
242: return StringPool.BLANK;
243: }
244: } else if (name.equals(USER_HOME_INFO_POSTAL_CITY)) {
245: if (_homeAddress != null) {
246: return _homeAddress.getCity();
247: } else {
248: return StringPool.BLANK;
249: }
250: } else if (name.equals(USER_HOME_INFO_POSTAL_STATEPROV)) {
251: return StringPool.BLANK;
252: } else if (name.equals(USER_HOME_INFO_POSTAL_POSTALCODE)) {
253: if (_homeAddress != null) {
254: return _homeAddress.getZip();
255: } else {
256: return StringPool.BLANK;
257: }
258: } else if (name.equals(USER_HOME_INFO_POSTAL_COUNTRY)) {
259: return StringPool.BLANK;
260: } else if (name.equals(USER_HOME_INFO_POSTAL_ORGANIZATION)) {
261: return StringPool.BLANK;
262: } else if (name
263: .equals(USER_HOME_INFO_TELECOM_TELEPHONE_INTCODE)) {
264: return StringPool.BLANK;
265: } else if (name
266: .equals(USER_HOME_INFO_TELECOM_TELEPHONE_LOCCODE)) {
267: return StringPool.BLANK;
268: } else if (name.equals(USER_HOME_INFO_TELECOM_TELEPHONE_NUMBER)) {
269: return StringPool.BLANK;
270: } else if (name.equals(USER_HOME_INFO_TELECOM_TELEPHONE_EXT)) {
271: return StringPool.BLANK;
272: } else if (name
273: .equals(USER_HOME_INFO_TELECOM_TELEPHONE_COMMENT)) {
274: return StringPool.BLANK;
275: } else if (name.equals(USER_HOME_INFO_TELECOM_FAX_INTCODE)) {
276: return StringPool.BLANK;
277: } else if (name.equals(USER_HOME_INFO_TELECOM_FAX_LOCCODE)) {
278: return StringPool.BLANK;
279: } else if (name.equals(USER_HOME_INFO_TELECOM_FAX_NUMBER)) {
280: return StringPool.BLANK;
281: } else if (name.equals(USER_HOME_INFO_TELECOM_FAX_EXT)) {
282: return StringPool.BLANK;
283: } else if (name.equals(USER_HOME_INFO_TELECOM_FAX_COMMENT)) {
284: return StringPool.BLANK;
285: } else if (name.equals(USER_HOME_INFO_TELECOM_MOBILE_INTCODE)) {
286: return StringPool.BLANK;
287: } else if (name.equals(USER_HOME_INFO_TELECOM_MOBILE_LOCCODE)) {
288: return StringPool.BLANK;
289: } else if (name.equals(USER_HOME_INFO_TELECOM_MOBILE_NUMBER)) {
290: return StringPool.BLANK;
291: } else if (name.equals(USER_HOME_INFO_TELECOM_MOBILE_EXT)) {
292: return StringPool.BLANK;
293: } else if (name.equals(USER_HOME_INFO_TELECOM_MOBILE_COMMENT)) {
294: return StringPool.BLANK;
295: } else if (name.equals(USER_HOME_INFO_TELECOM_PAGER_INTCODE)) {
296: return StringPool.BLANK;
297: } else if (name.equals(USER_HOME_INFO_TELECOM_PAGER_LOCCODE)) {
298: return StringPool.BLANK;
299: } else if (name.equals(USER_HOME_INFO_TELECOM_PAGER_NUMBER)) {
300: return StringPool.BLANK;
301: } else if (name.equals(USER_HOME_INFO_TELECOM_PAGER_EXT)) {
302: return StringPool.BLANK;
303: } else if (name.equals(USER_HOME_INFO_TELECOM_PAGER_COMMENT)) {
304: return StringPool.BLANK;
305: } else if (name.equals(USER_HOME_INFO_ONLINE_EMAIL)) {
306: return _user.getEmailAddress();
307: } else if (name.equals(USER_HOME_INFO_ONLINE_URI)) {
308: return StringPool.BLANK;
309: } else if (name.equals(USER_BUSINESS_INFO_POSTAL_NAME)) {
310: return StringPool.BLANK;
311: } else if (name.equals(USER_BUSINESS_INFO_POSTAL_STREET)) {
312: if (_bizAddress != null) {
313: return _bizAddress.getStreet1();
314: } else {
315: return StringPool.BLANK;
316: }
317: } else if (name.equals(USER_BUSINESS_INFO_POSTAL_CITY)) {
318: if (_bizAddress != null) {
319: return _bizAddress.getCity();
320: } else {
321: return StringPool.BLANK;
322: }
323: } else if (name.equals(USER_BUSINESS_INFO_POSTAL_STATEPROV)) {
324: return StringPool.BLANK;
325: } else if (name.equals(USER_BUSINESS_INFO_POSTAL_POSTALCODE)) {
326: if (_bizAddress != null) {
327: return _bizAddress.getZip();
328: } else {
329: return StringPool.BLANK;
330: }
331: } else if (name.equals(USER_BUSINESS_INFO_POSTAL_COUNTRY)) {
332: return StringPool.BLANK;
333: } else if (name.equals(USER_BUSINESS_INFO_POSTAL_ORGANIZATION)) {
334: return StringPool.BLANK;
335: } else if (name
336: .equals(USER_BUSINESS_INFO_TELECOM_TELEPHONE_INTCODE)) {
337: return StringPool.BLANK;
338: } else if (name
339: .equals(USER_BUSINESS_INFO_TELECOM_TELEPHONE_LOCCODE)) {
340: return StringPool.BLANK;
341: } else if (name
342: .equals(USER_BUSINESS_INFO_TELECOM_TELEPHONE_NUMBER)) {
343: return StringPool.BLANK;
344: } else if (name
345: .equals(USER_BUSINESS_INFO_TELECOM_TELEPHONE_EXT)) {
346: return StringPool.BLANK;
347: } else if (name
348: .equals(USER_BUSINESS_INFO_TELECOM_TELEPHONE_COMMENT)) {
349: return StringPool.BLANK;
350: } else if (name.equals(USER_BUSINESS_INFO_TELECOM_FAX_INTCODE)) {
351: return StringPool.BLANK;
352: } else if (name.equals(USER_BUSINESS_INFO_TELECOM_FAX_LOCCODE)) {
353: return StringPool.BLANK;
354: } else if (name.equals(USER_BUSINESS_INFO_TELECOM_FAX_NUMBER)) {
355: return StringPool.BLANK;
356: } else if (name.equals(USER_BUSINESS_INFO_TELECOM_FAX_EXT)) {
357: return StringPool.BLANK;
358: } else if (name.equals(USER_BUSINESS_INFO_TELECOM_FAX_COMMENT)) {
359: return StringPool.BLANK;
360: } else if (name
361: .equals(USER_BUSINESS_INFO_TELECOM_MOBILE_INTCODE)) {
362: return StringPool.BLANK;
363: } else if (name
364: .equals(USER_BUSINESS_INFO_TELECOM_MOBILE_LOCCODE)) {
365: return StringPool.BLANK;
366: } else if (name
367: .equals(USER_BUSINESS_INFO_TELECOM_MOBILE_NUMBER)) {
368: return StringPool.BLANK;
369: } else if (name.equals(USER_BUSINESS_INFO_TELECOM_MOBILE_EXT)) {
370: return StringPool.BLANK;
371: } else if (name
372: .equals(USER_BUSINESS_INFO_TELECOM_MOBILE_COMMENT)) {
373: return StringPool.BLANK;
374: } else if (name
375: .equals(USER_BUSINESS_INFO_TELECOM_PAGER_INTCODE)) {
376: return StringPool.BLANK;
377: } else if (name
378: .equals(USER_BUSINESS_INFO_TELECOM_PAGER_LOCCODE)) {
379: return StringPool.BLANK;
380: } else if (name.equals(USER_BUSINESS_INFO_TELECOM_PAGER_NUMBER)) {
381: return StringPool.BLANK;
382: } else if (name.equals(USER_BUSINESS_INFO_TELECOM_PAGER_EXT)) {
383: return StringPool.BLANK;
384: } else if (name
385: .equals(USER_BUSINESS_INFO_TELECOM_PAGER_COMMENT)) {
386: return StringPool.BLANK;
387: } else if (name.equals(USER_BUSINESS_INFO_ONLINE_EMAIL)) {
388: return _user.getEmailAddress();
389: } else if (name.equals(USER_BUSINESS_INFO_ONLINE_URI)) {
390: return StringPool.BLANK;
391: } else {
392: return null;
393: }
394: }
395:
396: private User _user;
397: private Address _homeAddress;
398: private Address _bizAddress;
399:
400: }
|