001: /**********************************************************************************
002: * $URL: https://source.sakaiproject.org/svn/profile/tags/sakai_2-4-1/common-composite-component-data/src/java/org/sakaiproject/component/common/edu/person/InetOrgPersonImpl.java $
003: * $Id: InetOrgPersonImpl.java 8921 2006-05-04 04:42:08Z lance@indiana.edu $
004: ***********************************************************************************
005: *
006: * Copyright (c) 2003, 2004, 2005, 2006 The Sakai Foundation.
007: *
008: * Licensed under the Educational Community License, Version 1.0 (the "License");
009: * you may not use this file except in compliance with the License.
010: * You may obtain a copy of the License at
011: *
012: * http://www.opensource.org/licenses/ecl1.php
013: *
014: * Unless required by applicable law or agreed to in writing, software
015: * distributed under the License is distributed on an "AS IS" BASIS,
016: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017: * See the License for the specific language governing permissions and
018: * limitations under the License.
019: *
020: **********************************************************************************/package org.sakaiproject.component.common.edu.person;
021:
022: import java.io.BufferedInputStream;
023: import java.io.BufferedOutputStream;
024: import java.io.ByteArrayOutputStream;
025: import java.io.IOException;
026: import java.io.InputStream;
027: import java.sql.Blob;
028: import java.sql.SQLException;
029:
030: import org.hibernate.Hibernate;
031:
032: import org.apache.commons.logging.Log;
033: import org.apache.commons.logging.LogFactory;
034: import org.sakaiproject.api.common.edu.person.InetOrgPerson;
035: import org.sakaiproject.api.common.edu.person.OrganizationalPerson;
036: import org.sakaiproject.api.common.edu.person.Person;
037:
038: /**
039: * @author <a href="mailto:lance@indiana.edu">Lance Speelmon </a>
040: */
041: public class InetOrgPersonImpl extends OrganizationalPersonImpl
042: implements Person, OrganizationalPerson, InetOrgPerson {
043: private static final Log LOG = LogFactory
044: .getLog(InetOrgPersonImpl.class);
045:
046: /**
047: * @see org.sakaiproject.service.profile.InetOrgPerson#getAudio()
048: */
049: public BufferedInputStream getAudio() {
050: // TODO implement audio
051: return null;
052: }
053:
054: /**
055: * @param audio
056: * The audio to set.
057: */
058: public void setAudio(BufferedOutputStream audio) {
059: // TODO implement audio
060: ;
061: }
062:
063: protected String givenName;
064:
065: /**
066: * @see org.sakaiproject.service.profile.InetOrgPerson#getGivenName()
067: */
068: public String getGivenName() {
069: return givenName;
070: }
071:
072: /**
073: * @param givenName
074: * The givenName to set.
075: */
076: public void setGivenName(String givenName) {
077: this .givenName = givenName;
078: }
079:
080: protected String homePhone;
081:
082: /**
083: * @see org.sakaiproject.service.profile.InetOrgPerson#getHomePhone()
084: */
085: public String getHomePhone() {
086: return homePhone;
087: }
088:
089: /**
090: * @param homePhone
091: * The homePhone to set.
092: */
093: public void setHomePhone(String homePhone) {
094: this .homePhone = homePhone;
095: }
096:
097: protected String homePostalAddress;
098:
099: /**
100: * @see org.sakaiproject.service.profile.InetOrgPerson#getHomePostalAddress()
101: */
102: public String getHomePostalAddress() {
103: return homePostalAddress;
104: }
105:
106: /**
107: * @param homePostalAddress
108: * The homePostalAddress to set.
109: */
110: public void setHomePostalAddress(String homePostalAddress) {
111: this .homePostalAddress = homePostalAddress;
112: }
113:
114: protected String initials;
115:
116: /**
117: * @see org.sakaiproject.service.profile.InetOrgPerson#getInitials()
118: */
119: public String getInitials() {
120: return initials;
121: }
122:
123: /**
124: * @param initials
125: * The initials to set.
126: */
127: public void setInitials(String initials) {
128: this .initials = initials;
129: }
130:
131: protected byte[] jpegPhoto;
132:
133: /**
134: * @see org.sakaiproject.service.profile.InetOrgPerson#getJpegPhoto()
135: */
136: public byte[] getJpegPhoto() {
137: return jpegPhoto;
138: }
139:
140: /**
141: * @param jpegPhoto
142: * The jpegPhoto to set.
143: */
144: public void setJpegPhoto(byte[] jpegPhoto) {
145: this .jpegPhoto = jpegPhoto;
146: }
147:
148: protected String labeledURI;
149:
150: /**
151: * @see org.sakaiproject.service.profile.InetOrgPerson#getLabeledURI()
152: */
153: public String getLabeledURI() {
154: return labeledURI;
155: }
156:
157: /**
158: * @param labeledURI
159: * The labeledURI to set.
160: */
161: public void setLabeledURI(String labeledURI) {
162: this .labeledURI = labeledURI;
163: }
164:
165: protected String mail;
166:
167: /**
168: * @see org.sakaiproject.service.profile.InetOrgPerson#getMail()
169: */
170: public String getMail() {
171: return mail;
172: }
173:
174: /**
175: * @param mail
176: * The mail to set.
177: */
178: public void setMail(String mail) {
179: this .mail = mail;
180: }
181:
182: protected String manager;
183:
184: /**
185: * @see org.sakaiproject.service.profile.InetOrgPerson#getManager()
186: */
187: public String getManager() {
188: return manager;
189: }
190:
191: /**
192: * @param manager
193: * The manager to set.
194: */
195: public void setManager(String manager) {
196: this .manager = manager;
197: }
198:
199: protected String mobile;
200:
201: /**
202: * @see org.sakaiproject.service.profile.InetOrgPerson#getMobile()
203: */
204: public String getMobile() {
205: return mobile;
206: }
207:
208: /**
209: * @param mobile
210: * The mobile to set.
211: */
212: public void setMobile(String mobile) {
213: this .mobile = mobile;
214: }
215:
216: protected String organization;
217:
218: /**
219: * @see org.sakaiproject.service.profile.InetOrgPerson#getOrganization()
220: */
221: public String getOrganization() {
222: return organization;
223: }
224:
225: /**
226: * @param organization
227: * The organization to set.
228: */
229: public void setOrganization(String organization) {
230: this .organization = organization;
231: }
232:
233: protected String pager;
234:
235: /**
236: * @see org.sakaiproject.service.profile.InetOrgPerson#getPager()
237: */
238: public String getPager() {
239: return pager;
240: }
241:
242: /**
243: * @param pager
244: * The pager to set.
245: */
246: public void setPager(String pager) {
247: this .pager = pager;
248: }
249:
250: protected String preferredLanguage;
251:
252: /**
253: * @see org.sakaiproject.service.profile.InetOrgPerson#getPreferredLanguage()
254: */
255: public String getPreferredLanguage() {
256: return preferredLanguage;
257: }
258:
259: /**
260: * @param preferredLanguage
261: * The preferredLanguage to set.
262: */
263: public void setPreferredLanguage(String preferredLanguage) {
264: this .preferredLanguage = preferredLanguage;
265: }
266:
267: protected String uid;
268:
269: /**
270: * @see org.sakaiproject.service.profile.InetOrgPerson#getUid()
271: */
272: public String getUid() {
273: return uid;
274: }
275:
276: /**
277: * @param uid
278: * The uid to set.
279: */
280: public void setUid(String uid) {
281: this .uid = uid;
282: }
283:
284: protected byte[] userCertificate;
285:
286: /**
287: * @see org.sakaiproject.service.profile.InetOrgPerson#getUserCertificate()
288: */
289: public byte[] getUserCertificate() {
290: return userCertificate;
291: }
292:
293: /**
294: * @param userCertificate
295: * The userCertificate to set.
296: */
297: public void setUserCertificate(byte[] userCertificate) {
298: this .userCertificate = userCertificate;
299: }
300:
301: protected byte[] userSMIMECertificate;
302:
303: /**
304: * @see org.sakaiproject.service.profile.InetOrgPerson#getUserSMIMECertificate()
305: */
306: public byte[] getUserSMIMECertificate() {
307: return userSMIMECertificate;
308: }
309:
310: /**
311: * @param userSMIMECertificate
312: * The userSMIMECertificate to set.
313: */
314: public void setUserSMIMECertificate(byte[] userSMIMECertificate) {
315: this .userSMIMECertificate = userSMIMECertificate;
316: }
317:
318: protected String carLicense;
319:
320: /**
321: * @see org.sakaiproject.service.profile.InetOrgPerson#getCarLicense()
322: */
323: public String getCarLicense() {
324: return carLicense;
325: }
326:
327: /**
328: * @param carLicense
329: * The carLicense to set.
330: */
331: public void setCarLicense(String carLicense) {
332: this .carLicense = carLicense;
333: }
334:
335: protected String displayName;
336:
337: /**
338: * @see org.sakaiproject.service.profile.InetOrgPerson#getDisplayName()
339: */
340: public String getDisplayName() {
341: return displayName;
342: }
343:
344: /**
345: * @param displayName
346: * The displayName to set.
347: */
348: public void setDisplayName(String displayName) {
349: this .displayName = displayName;
350: }
351:
352: protected String departmentNumber;
353:
354: /**
355: * @see org.sakaiproject.service.profile.InetOrgPerson#getDepartmentNumber()
356: */
357: public String getDepartmentNumber() {
358: return departmentNumber;
359: }
360:
361: /**
362: * @param departmentNumber
363: * The departmentNumber to set.
364: */
365: public void setDepartmentNumber(String departmentNumber) {
366: this .departmentNumber = departmentNumber;
367: }
368:
369: protected String employeeNumber;
370:
371: /**
372: * @see org.sakaiproject.service.profile.InetOrgPerson#getEmployeeNumber()
373: */
374: public String getEmployeeNumber() {
375: return employeeNumber;
376: }
377:
378: /**
379: * @param employeeNumber
380: * The employeeNumber to set.
381: */
382: public void setEmployeeNumber(String employeeNumber) {
383: this .employeeNumber = employeeNumber;
384: }
385:
386: protected String employeeType;
387:
388: /**
389: * @see org.sakaiproject.service.profile.InetOrgPerson#getEmployeeType()
390: */
391: public String getEmployeeType() {
392: return employeeType;
393: }
394:
395: /**
396: * @param employeeType
397: * The employeeType to set.
398: */
399: public void setEmployeeType(String employeeType) {
400: this .employeeType = employeeType;
401: }
402:
403: protected byte[] userPKCS12;
404:
405: /**
406: * @see org.sakaiproject.service.profile.InetOrgPerson#getUserPKCS12()
407: */
408: public byte[] getUserPKCS12() {
409: return userPKCS12;
410: }
411:
412: /**
413: * @param userPKCS12
414: * The userPKCS12 to set.
415: */
416: public void setUserPKCS12(byte[] userPKCS12) {
417: this .userPKCS12 = userPKCS12;
418: }
419:
420: protected String businessCategory;
421:
422: /**
423: * @see org.sakaiproject.service.profile.InetOrgPerson#getBusinessCategory()
424: */
425: public String getBusinessCategory() {
426: return businessCategory;
427: }
428:
429: /**
430: * @param businessCategory
431: * The businessCategory to set.
432: */
433: public void setBusinessCategory(String businessCategory) {
434: this .businessCategory = businessCategory;
435: }
436:
437: protected String x500UniqueIdentifier;
438:
439: /**
440: * @see org.sakaiproject.service.profile.InetOrgPerson#getX500UniqueIdentifier()
441: */
442: public String getX500UniqueIdentifier() {
443: return x500UniqueIdentifier;
444: }
445:
446: /**
447: * @param uniqueIdentifier
448: * The x500UniqueIdentifier to set.
449: */
450: public void setX500UniqueIdentifier(String uniqueIdentifier) {
451: x500UniqueIdentifier = uniqueIdentifier;
452: }
453:
454: protected String roomNumber;
455:
456: /**
457: * @see org.sakaiproject.service.profile.InetOrgPerson#getRoomNumber()
458: */
459: public String getRoomNumber() {
460: return roomNumber;
461: }
462:
463: /**
464: * @param roomNumber
465: * The roomNumber to set.
466: */
467: public void setRoomNumber(String roomNumber) {
468: this .roomNumber = roomNumber;
469: }
470:
471: protected String secretary;
472:
473: /**
474: * @see org.sakaiproject.service.profile.InetOrgPerson#getSecretary()
475: */
476: public String getSecretary() {
477: return secretary;
478: }
479:
480: /**
481: * @param secretary
482: * The secretary to set.
483: */
484: public void setSecretary(String secretary) {
485: this .secretary = secretary;
486: }
487:
488: public Blob getBlobImage() {
489: if (this .jpegPhoto == null || jpegPhoto.length < 1) {
490: return null;
491: }
492: return Hibernate.createBlob(this .jpegPhoto);
493: }
494:
495: public void setBlobImage(Blob blobImage) {
496: this .jpegPhoto = toByteArray(blobImage);
497: }
498:
499: private byte[] toByteArray(Blob fromBlob) {
500: if (LOG.isDebugEnabled()) {
501: LOG.debug("toByteArray(Blob " + fromBlob + ")");
502: }
503:
504: try {
505: if (fromBlob == null || fromBlob.length() < 1) {
506: return null;
507: }
508: } catch (SQLException e1) {
509: LOG.error(e1.getMessage(), e1);
510: }
511: ByteArrayOutputStream baos = new ByteArrayOutputStream();
512: try {
513: return toByteArray(fromBlob, baos);
514: } catch (Exception e) {
515: LOG.error(e.getMessage(), e);
516: throw new Error(e);
517: } finally {
518: if (baos != null) {
519: try {
520: baos.close();
521: } catch (IOException ex) {
522: LOG.error(ex.getMessage(), ex);
523: }
524: }
525: }
526: }
527:
528: private byte[] toByteArray(Blob fromBlob, ByteArrayOutputStream baos)
529: throws SQLException, IOException {
530: if (LOG.isDebugEnabled()) {
531: LOG.debug("toByteArray(Blob " + fromBlob
532: + ", ByteArrayOutputStream " + baos + ")");
533: }
534:
535: if (fromBlob == null || fromBlob.length() < 1) {
536: return null;
537: }
538: byte[] buf = new byte[4000];
539: InputStream is = fromBlob.getBinaryStream();
540: try {
541: for (;;) {
542: int dataSize = is.read(buf);
543:
544: if (dataSize == -1)
545: break;
546: baos.write(buf, 0, dataSize);
547: }
548: } finally {
549: if (is != null) {
550: try {
551: is.close();
552: } catch (IOException ex) {
553: LOG.error(ex.getMessage(), ex);
554: }
555: }
556: }
557: return baos.toByteArray();
558: }
559:
560: }
|