001: /**
002: * LibreSource
003: * Copyright (C) 2004-2008 Artenum SARL / INRIA
004: * http://www.libresource.org - contact@artenum.com
005: *
006: * This file is part of the LibreSource software,
007: * which can be used and distributed under license conditions.
008: * The license conditions are provided in the LICENSE.TXT file
009: * at the root path of the packaging that enclose this file.
010: * More information can be found at
011: * - http://dev.libresource.org/home/license
012: *
013: * Initial authors :
014: *
015: * Guillaume Bort / INRIA
016: * Francois Charoy / Universite Nancy 2
017: * Julien Forest / Artenum
018: * Claude Godart / Universite Henry Poincare
019: * Florent Jouille / INRIA
020: * Sebastien Jourdain / INRIA / Artenum
021: * Yves Lerumeur / Artenum
022: * Pascal Molli / Universite Henry Poincare
023: * Gerald Oster / INRIA
024: * Mariarosa Penzi / Artenum
025: * Gerard Sookahet / Artenum
026: * Raphael Tani / INRIA
027: *
028: * Contributors :
029: *
030: * Stephane Bagnier / Artenum
031: * Amadou Dia / Artenum-IUP Blois
032: * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
033: */package org.libresource.membership.ejb;
034:
035: import org.libresource.LibresourceResourceBase;
036:
037: import java.util.Date;
038: import java.util.HashMap;
039:
040: import javax.ejb.CreateException;
041:
042: /**
043: * LibreSource
044: *
045: * @author <a href="mailto:jouille@loria.fr">Florent Jouille</a> - <a href="http://www.inria.fr">INRIA Lorraine</a>
046: *
047: * A User Profile of the Membership service
048: *
049: * @libresource.resource name="Profile" service="Membership"
050: *
051: */
052: public abstract class ProfileResourceBean extends
053: LibresourceResourceBase {
054: /**
055: * @ejb.create-method
056: */
057: public String ejbCreate(String username, String fullName,
058: String email, String jabberId, HashMap infos)
059: throws CreateException {
060: // user infos
061: setId(username);
062: setFullName(fullName);
063: setEmail(email);
064: setJabberId(jabberId);
065: setInfos(infos);
066: setAccountStatus(0);
067: setOnlineStatus(0);
068:
069: return null;
070: }
071:
072: // persistents fields
073:
074: /**
075: * @ejb.persistent-field
076: * @ejb.interface-method
077: * @ejb.value-object match="libresource"
078: * @ejb.transaction type="Supports"
079: */
080: public abstract String getId();
081:
082: /**
083: * @ejb.persistent-field
084: * @ejb.interface-method
085: * @ejb.transaction type="Mandatory"
086: */
087: public abstract void setId(String id);
088:
089: /**
090: * @ejb.interface-method
091: * @ejb.value-object match="libresource"
092: * @ejb.transaction type="Supports"
093: */
094: public String getShortResourceName() {
095: String shortName = getFullName();
096:
097: if ((shortName == null) || (shortName.trim().length() == 0)) {
098: shortName = getId();
099: }
100:
101: return shortName;
102: }
103:
104: /**
105: * @ejb.persistent-field
106: * @ejb.interface-method
107: * @ejb.value-object match="libresource"
108: * @ejb.transaction type="Supports"
109: */
110: public abstract String getFullName();
111:
112: /**
113: * @ejb.persistent-field
114: * @ejb.interface-method
115: * @ejb.transaction type="Mandatory"
116: */
117: public abstract void setFullName(String fullName);
118:
119: /**
120: * @ejb.persistent-field
121: * @ejb.interface-method
122: * @ejb.value-object match="libresource"
123: * @ejb.transaction type="Supports"
124: */
125: public abstract String getEmail();
126:
127: /**
128: * @ejb.persistent-field
129: * @ejb.interface-method
130: * @ejb.transaction type="Mandatory"
131: */
132: public abstract void setEmail(String email);
133:
134: /**
135: * @ejb.persistent-field
136: * @ejb.interface-method
137: * @ejb.value-object match="libresource"
138: * @ejb.transaction type="Supports"
139: */
140: public abstract String getJabberId();
141:
142: /**
143: * @ejb.persistent-field
144: * @ejb.interface-method
145: * @ejb.transaction type="Mandatory"
146: */
147: public abstract void setJabberId(String jabberId);
148:
149: // tigase add-on
150:
151: /**
152: * @ejb.persistent-field
153: * @ejb.interface-method
154: * @ejb.value-object match="libresource"
155: * @ejb.transaction type="Supports"
156: */
157: public abstract int getAccountStatus();
158:
159: /**
160: * @ejb.persistent-field
161: * @ejb.interface-method
162: * @ejb.transaction type="Mandatory"
163: */
164: public abstract void setAccountStatus(int accountStatus);
165:
166: /**
167: * @ejb.persistent-field
168: * @ejb.interface-method
169: * @ejb.value-object match="libresource"
170: * @ejb.transaction type="Supports"
171: */
172: public abstract int getOnlineStatus();
173:
174: /**
175: * @ejb.persistent-field
176: * @ejb.interface-method
177: * @ejb.transaction type="Mandatory"
178: */
179: public abstract void setOnlineStatus(int onlineStatus);
180:
181: /**
182: * @ejb.persistent-field
183: * @ejb.interface-method
184: * @ejb.value-object match="libresource"
185: * @ejb.transaction type="Supports"
186: */
187: public abstract Date getLastLoginTime();
188:
189: /**
190: * @ejb.persistent-field
191: * @ejb.interface-method
192: * @ejb.transaction type="Mandatory"
193: */
194: public abstract void setLastLoginTime(Date lastLoginTime);
195:
196: /**
197: * @ejb.persistent-field
198: * @ejb.interface-method
199: * @ejb.value-object match="libresource"
200: * @ejb.transaction type="Supports"
201: */
202: public abstract HashMap getInfos();
203:
204: /**
205: * @ejb.persistent-field
206: * @ejb.interface-method
207: * @ejb.transaction type="Mandatory"
208: */
209: public abstract void setInfos(HashMap infos);
210:
211: // business methods
212:
213: /**
214: * @ejb.interface-method
215: * @ejb.transaction type="Mandatory"
216: */
217: public void updateLastLoginTime() {
218: setLastLoginTime(new Date());
219: }
220:
221: /**
222: * @ejb.interface-method
223: * @ejb.transaction type="Mandatory"
224: */
225: public void setInfo(String key, Object value) {
226: HashMap infos = getInfos();
227: infos.put(key, value);
228: setInfos(infos);
229: }
230:
231: /**
232: * @ejb.interface-method
233: * @ejb.transaction type="Mandatory"
234: */
235: public void removeInfo(String key) {
236: HashMap infos = getInfos();
237: infos.remove(key);
238: setInfos(infos);
239: }
240: }
|