Source Code Cross Referenced for UserSoapXMLBean.java in  » Workflow-Engines » bonita-v3.1 » hero » session » 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 » Workflow Engines » bonita v3.1 » hero.session 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package hero.session;
002:
003:        /*
004:         * 1Z/01/2004 - 11:58:09
005:         *
006:         * UserSoapXML.java - 
007:         * Copyright (C) 2003 Ecoo Team
008:         * valdes@loria.fr
009:         * 
010:         *
011:         * This program is free software; you can redistribute it and/or
012:         * modify it under the terms of the GNU Lesser General Public License
013:         * as published by the Free Software Foundation; either version 2
014:         * of the License, or (at your option) any later version.
015:         *
016:         * This program is distributed in the hope that it will be useful,
017:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
018:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
019:         * GNU Lesser General Public License for more details.
020:         *
021:         * You should have received a copy of the GNU Lesser General Public License
022:         * along with this program; if not, write to the Free Software
023:         * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
024:         */
025:        import hero.interfaces.BnNodeLocal;
026:        import hero.interfaces.BnNodeLocalHome;
027:        import hero.interfaces.BnNodeUtil;
028:        import hero.interfaces.BnProjectLocal;
029:        import hero.interfaces.BnProjectLocalHome;
030:        import hero.interfaces.BnProjectUtil;
031:        import hero.interfaces.BnUserLightValue;
032:        import hero.interfaces.BnUserLocal;
033:        import hero.interfaces.BnUserLocalHome;
034:        import hero.interfaces.BnUserPropertyLocal;
035:        import hero.interfaces.BnUserValue;
036:        import hero.interfaces.Constants;
037:        import hero.interfaces.ProjectSessionLocal;
038:        import hero.interfaces.UserServiceLocal;
039:        import hero.interfaces.UserServiceLocalHome;
040:        import hero.util.HeroException;
041:        import hero.util.ProjectNodes;
042:        import hero.util.Projects;
043:        import hero.util.UserProperties;
044:        import hero.util.EventConstants;
045:
046:        import java.io.StringWriter;
047:        import java.util.ArrayList;
048:        import java.util.Arrays;
049:        import java.util.Collection;
050:        import java.util.Iterator;
051:        import java.util.Map;
052:
053:        import javax.ejb.CreateException;
054:        import javax.ejb.FinderException;
055:        import javax.ejb.SessionBean;
056:        import javax.ejb.SessionContext;
057:
058:        import org.apache.log4j.Category;
059:        import org.exolab.castor.xml.MarshalException;
060:        import org.exolab.castor.xml.Marshaller;
061:        import org.exolab.castor.xml.ValidationException;
062:
063:        /**
064:         * UserSessionXML API based on UserSession API but oriented to web services 
065:         * calls from a non-Java language. Get methods of this API returns
066:         * XML.
067:         *
068:         * @ejb:bean name="UserSoapXML"
069:         *           display-name="UserSoapXML Bean"
070:         *           type="Stateless"
071:         *           transaction-type="Container"
072:         *           jndi-name="ejb/hero/UserSoapXML"
073:         *
074:         * @ejb:ejb-ref ejb-name="BnUser"
075:         *              ref-name="myhero/BnUser"
076:         * @ejb.permission role-name="BONITAUSER,user,SuperAdmin"
077:         *
078:         * @jonas.bean
079:         *      ejb-name="UserSoapXML"
080:         *      jndi-name="ejb/hero/UserSoapXML"
081:         * 
082:         * @jboss.container-configuration name="Standard Stateless SessionBean for Bonita"
083:         * 
084:         * @copyright INRIA
085:         * @author Miguel Valdes
086:         * 
087:         **/
088:
089:        public class UserSoapXMLBean implements  SessionBean, EventConstants {
090:
091:            // -------------------------------------------------------------------------
092:            // Static
093:            // -------------------------------------------------------------------------
094:            // Utility variable
095:            private static final Category trace = Category
096:                    .getInstance(UserSessionBean.class);
097:
098:            // -------------------------------------------------------------------------
099:            // Members 
100:            // -------------------------------------------------------------------------
101:
102:            private SessionContext mContext;
103:
104:            // -------------------------------------------------------------------------
105:            // XML Get Methods (Castor Data Binding)
106:            // -------------------------------------------------------------------------
107:
108:            /**
109:             * Get user project list. Workflow processes associated to this user
110:             * @return a Collection of BnProjectLightValue objects - the projects list of the user
111:             * @throws HeroException
112:             * @ejb:interface-method view-type="both"
113:             * @ejb:transaction type="Supports"
114:             *
115:             **/
116:            public String getProjectList() throws HeroException {
117:                trace.debug("start by "
118:                        + mContext.getCallerPrincipal().getName());
119:                Collection pjts = new ArrayList();
120:                Projects pb = new Projects();
121:                Collection pva;
122:                try {
123:                    BnUserLocalHome userhome = hero.interfaces.BnUserUtil
124:                            .getLocalHome();
125:                    BnUserLocal mUser = userhome.findByName(mContext
126:                            .getCallerPrincipal().getName());
127:                    Collection projects = null;
128:                    projects = mUser.getBnProjects();
129:                    BnUserValue uv = mUser.getBnUserValue();
130:                    hero.interfaces.BnProjectLightValue[] pv = uv
131:                            .getBnProjects();
132:                    pva = new ArrayList(Arrays.asList(uv.getBnProjects()));
133:                } catch (javax.naming.NamingException ne) {
134:                    throw new HeroException(ne.getMessage());
135:                } catch (javax.ejb.FinderException fe) {
136:                    throw new HeroException(mContext.getCallerPrincipal()
137:                            .getName()
138:                            + " does not exists");
139:                }
140:
141:                try {
142:                    pb.setProject(pva);
143:                    StringWriter sw = new StringWriter();
144:                    Marshaller.marshal(pb, sw);
145:                    return (sw.toString());
146:                } catch (MarshalException ex1) {
147:                    throw new HeroException(ex1.getMessage());
148:                } catch (ValidationException ex2) {
149:                    throw new HeroException(ex2.getMessage());
150:                }
151:            }
152:
153:            /**
154:             * Obtain all user activities from specific project (ready and anticipable state)
155:             * @param projectName the name of the project
156:             * @return a String Collection - the list of todo activities ot the user for a project
157:             * @throws HeroException
158:             * @ejb:interface-method view-type="both"
159:             * @ejb:transaction type="Supports"
160:             *
161:             **/
162:            public String getToDoList(String projectName) throws HeroException {
163:                trace
164:                        .debug("parameter: projectName=" + projectName
165:                                + "start by "
166:                                + mContext.getCallerPrincipal().getName());
167:                ProjectNodes nb = new ProjectNodes();
168:                BnProjectLocalHome projhome;
169:                BnProjectLocal project;
170:                BnNodeLocalHome nodehome;
171:                Collection ready;
172:                try {
173:                    projhome = BnProjectUtil.getLocalHome();
174:                    nodehome = BnNodeUtil.getLocalHome();
175:                } catch (javax.naming.NamingException ne) {
176:                    throw new HeroException(ne.getMessage());
177:                }
178:                try {
179:                    project = projhome.findByName(projectName);
180:                } catch (FinderException fe) {
181:                    throw new HeroException("BnProject " + projectName
182:                            + " does not exists");
183:                }
184:                try {
185:                    ready = nodehome.findUserReady(project.getId(), mContext
186:                            .getCallerPrincipal().getName());
187:                } catch (FinderException fe) {
188:                    ready = new ArrayList();
189:                }
190:                ArrayList result = new ArrayList();
191:                for (Iterator i = ready.iterator(); i.hasNext();) {
192:                    BnNodeLocal nd = (BnNodeLocal) i.next();
193:                    result.add(nd.getBnNodeLightValue());
194:                }
195:                try {
196:                    nb.setNodes(result.toArray());
197:                    StringWriter sw = new StringWriter();
198:                    Marshaller.marshal(nb, sw);
199:                    return (sw.toString());
200:                } catch (MarshalException ex1) {
201:                    throw new HeroException(ex1.getMessage());
202:                } catch (ValidationException ex2) {
203:                    throw new HeroException(ex2.getMessage());
204:                }
205:            }
206:
207:            /**
208:             * Obtain all user activities from specific project (ready and anticipable state)
209:             * @param projectName the name of the project
210:             * @return a String Collection - the list of todo activities ot the user for a project
211:             * @throws HeroException
212:             * @ejb:interface-method view-type="both"
213:             * @ejb:transaction type="Supports"
214:             *
215:             **/
216:            public String getToDoList(String projectName, int offset,
217:                    int numrows) throws HeroException {
218:                trace
219:                        .debug("parameter: projectName=" + projectName
220:                                + "start by "
221:                                + mContext.getCallerPrincipal().getName());
222:                ProjectNodes nb = new ProjectNodes();
223:                BnProjectLocalHome projhome;
224:                BnProjectLocal project;
225:                BnNodeLocalHome nodehome;
226:                Collection ready;
227:                try {
228:                    projhome = BnProjectUtil.getLocalHome();
229:                    nodehome = BnNodeUtil.getLocalHome();
230:                } catch (javax.naming.NamingException ne) {
231:                    throw new HeroException(ne.getMessage());
232:                }
233:                try {
234:                    project = projhome.findByName(projectName);
235:                } catch (FinderException fe) {
236:                    throw new HeroException("BnProject " + projectName
237:                            + " does not exists");
238:                }
239:                try {
240:                    ready = nodehome.findUserReady(project.getId(), mContext
241:                            .getCallerPrincipal().getName());
242:                } catch (FinderException fe) {
243:                    ready = new ArrayList();
244:                }
245:                int cnt = 0;
246:                int add = 0;
247:                ArrayList result = new ArrayList();
248:                for (Iterator i = ready.iterator(); i.hasNext();) {
249:                    BnNodeLocal nd = (BnNodeLocal) i.next();
250:                    if (cnt >= offset) {
251:                        result.add(nd.getBnNodeLightValue());
252:                        add++;
253:                        if (add == numrows)
254:                            break;
255:                    }
256:                    cnt++;
257:                }
258:                try {
259:                    nb.setNodes(result.toArray());
260:                    StringWriter sw = new StringWriter();
261:                    Marshaller.marshal(nb, sw);
262:                    return (sw.toString());
263:                } catch (MarshalException ex1) {
264:                    throw new HeroException(ex1.getMessage());
265:                } catch (ValidationException ex2) {
266:                    throw new HeroException(ex2.getMessage());
267:                }
268:            }
269:
270:            /**
271:             * Obtain all user activities from specific project (executing and anticipating state)
272:             *
273:             * @param projectName the name of the project
274:             * @return a String Collectio - the list of active activities ot the user for a project
275:             * @throws HeroException
276:             * @ejb:interface-method view-type="both"
277:             * @ejb:transaction type="Supports"
278:             *
279:             **/
280:            public String getActivityList(String projectName)
281:                    throws HeroException {
282:                trace
283:                        .debug("parameter: projectName=" + projectName
284:                                + "start by "
285:                                + mContext.getCallerPrincipal().getName());
286:                ProjectNodes nb = new ProjectNodes();
287:                BnProjectLocalHome projhome;
288:                BnProjectLocal project;
289:                BnNodeLocalHome nodehome;
290:                Collection executing;
291:                try {
292:                    projhome = BnProjectUtil.getLocalHome();
293:                    nodehome = BnNodeUtil.getLocalHome();
294:                } catch (javax.naming.NamingException ne) {
295:                    throw new HeroException(ne.getMessage());
296:                }
297:                try {
298:                    project = projhome.findByName(projectName);
299:                } catch (FinderException fe) {
300:                    throw new HeroException("BnProject " + projectName
301:                            + " does not exists");
302:                }
303:                try {
304:                    executing = nodehome.findUserExecuting(project.getId(),
305:                            mContext.getCallerPrincipal().getName());
306:                } catch (FinderException fe) {
307:                    executing = new ArrayList();
308:                }
309:                ArrayList result = new ArrayList();
310:                for (Iterator i = executing.iterator(); i.hasNext();) {
311:                    BnNodeLocal nd = (BnNodeLocal) i.next();
312:                    result.add(nd.getBnNodeLightValue());
313:                }
314:                try {
315:                    nb.setNodes(result.toArray());
316:                    StringWriter sw = new StringWriter();
317:                    Marshaller.marshal(nb, sw);
318:                    return (sw.toString());
319:                } catch (MarshalException ex1) {
320:                    throw new HeroException(ex1.getMessage());
321:                } catch (ValidationException ex2) {
322:                    throw new HeroException(ex2.getMessage());
323:                }
324:            }
325:
326:            /**
327:             * Obtain all user activities from specific project (executing and anticipating state)
328:             *
329:             * @param projectName the name of the project
330:             * @return a String Collectio - the list of active activities ot the user for a project
331:             * @throws HeroException
332:             * @ejb:interface-method view-type="both"
333:             * @ejb:transaction type="Supports"
334:             *
335:             **/
336:            public String getActivityList(String projectName, int offset,
337:                    int numrows) throws HeroException {
338:                trace
339:                        .debug("parameter: projectName=" + projectName
340:                                + "start by "
341:                                + mContext.getCallerPrincipal().getName());
342:                ProjectNodes nb = new ProjectNodes();
343:                BnProjectLocalHome projhome;
344:                BnProjectLocal project;
345:                BnNodeLocalHome nodehome;
346:                Collection executing;
347:                try {
348:                    projhome = BnProjectUtil.getLocalHome();
349:                    nodehome = BnNodeUtil.getLocalHome();
350:                } catch (javax.naming.NamingException ne) {
351:                    throw new HeroException(ne.getMessage());
352:                }
353:                try {
354:                    project = projhome.findByName(projectName);
355:                } catch (FinderException fe) {
356:                    throw new HeroException("BnProject " + projectName
357:                            + " does not exists");
358:                }
359:                try {
360:                    executing = nodehome.findUserExecuting(project.getId(),
361:                            mContext.getCallerPrincipal().getName());
362:                } catch (FinderException fe) {
363:                    executing = new ArrayList();
364:                }
365:                int cnt = 0;
366:                int add = 0;
367:                ArrayList result = new ArrayList();
368:                for (Iterator i = executing.iterator(); i.hasNext();) {
369:                    BnNodeLocal nd = (BnNodeLocal) i.next();
370:                    if (cnt >= offset) {
371:                        result.add(nd.getBnNodeLightValue());
372:                        add++;
373:                        if (add == numrows)
374:                            break;
375:                    }
376:                    cnt++;
377:                }
378:                try {
379:                    nb.setNodes(result.toArray());
380:                    StringWriter sw = new StringWriter();
381:                    Marshaller.marshal(nb, sw);
382:                    return (sw.toString());
383:                } catch (MarshalException ex1) {
384:                    throw new HeroException(ex1.getMessage());
385:                } catch (ValidationException ex2) {
386:                    throw new HeroException(ex2.getMessage());
387:                }
388:            }
389:
390:            /**
391:             * Get number of total entities
392:             * 
393:             * @ejb:interface-method view-type="both"
394:             * @ejb:transaction type="Supports"
395:             *
396:             **/
397:            public int getListCnt(String projectName, String type)
398:                    throws HeroException {
399:                trace.debug("parameter: projectName=" + projectName + ", type="
400:                        + type + "start by "
401:                        + mContext.getCallerPrincipal().getName());
402:                Collection list = null;
403:                int cnt = 0;
404:                BnProjectLocal project;
405:                BnNodeLocalHome nodehome;
406:                BnProjectLocalHome projhome;
407:
408:                try {
409:                    if (type.equals(Constants.Pj.GETACTIVITYLIST)
410:                            || type.equals(Constants.Pj.GETTODOLIST)) {
411:                        nodehome = hero.interfaces.BnNodeUtil.getLocalHome();
412:                        projhome = hero.interfaces.BnProjectUtil.getLocalHome();
413:                        System.out.println("Antes del findByName...");
414:                        project = projhome.findByName(projectName);
415:                        System.out.println("Despues del findByName...");
416:                        list = nodehome.findUserExecuting(project.getId(),
417:                                mContext.getCallerPrincipal().getName());
418:                    }
419:                    Iterator it = list.iterator();
420:                    while (it.hasNext()) {
421:                        it.next();
422:                        cnt++;
423:                    }
424:                } catch (javax.naming.NamingException ne) {
425:                    trace.error(ne.getMessage());
426:                    throw new HeroException(ne.getMessage());
427:                } catch (javax.ejb.FinderException fe) {
428:                    trace.error(fe.getMessage());
429:                    throw new HeroException(fe.getMessage());
430:                }
431:                return cnt;
432:            }
433:
434:            /**
435:             * Get the user light value
436:             * 
437:             * @return a BnUserLightValue object - get user information
438:             * @ejb:interface-method view-type="both"
439:             * @ejb:transaction type="Supports"
440:             **/
441:            public BnUserLightValue getUserLightValue() throws HeroException {
442:                try {
443:                    trace.debug("start by "
444:                            + mContext.getCallerPrincipal().getName());
445:                    BnUserLocalHome userhome = hero.interfaces.BnUserUtil
446:                            .getLocalHome();
447:                    BnUserLocal mUser = userhome.findByName(mContext
448:                            .getCallerPrincipal().getName());
449:                    BnUserLightValue ulv = mUser.getBnUserLightValue();
450:                    UserServiceLocalHome ushome = null;
451:                    try {
452:                        ushome = hero.interfaces.UserServiceUtil.getLocalHome();
453:                        UserServiceLocal ul = ushome.create();
454:                        Map infos = ul.getUserInfos(mContext
455:                                .getCallerPrincipal().getName());
456:                        ulv.setEmail((String) infos.get("email"));
457:                        ulv.setPassword((String) infos.get("password"));
458:                        ulv.setJabber((String) infos.get("jabber"));
459:                        return ulv;
460:                    } catch (Exception ce) {
461:                        trace.error(ce.getMessage());
462:                        throw new HeroException(ce.getMessage());
463:                    }
464:                } catch (javax.naming.NamingException ne) {
465:                    trace.error(ne.getMessage());
466:                    throw new HeroException(ne.getMessage());
467:                } catch (javax.ejb.FinderException fe) {
468:                    trace.error(mContext.getCallerPrincipal().getName()
469:                            + " does not exists " + fe.getMessage());
470:                    throw new HeroException(mContext.getCallerPrincipal()
471:                            .getName()
472:                            + " does not exists");
473:                }
474:            }
475:
476:            /**
477:             * Get the user name
478:             * 
479:             * @return a String - get user name
480:             * @ejb:interface-method view-type="both"
481:             * @ejb:transaction type="Supports"
482:             **/
483:            public String getUser() {
484:                trace.debug("start by "
485:                        + mContext.getCallerPrincipal().getName());
486:                return mContext.getCallerPrincipal().getName();
487:            }
488:
489:            /**
490:             * Get the mail of this user from Bonita database.
491:             *
492:             * @param userName the name of the user
493:             * @ejb:interface-method view-type="both"
494:             * @ejb:transaction type="Supports"
495:             * @throws HeroException
496:             *
497:             **/
498:            public String getUserMail() throws HeroException {
499:                trace.debug("start by "
500:                        + mContext.getCallerPrincipal().getName());
501:                UserServiceLocalHome ushome = null;
502:                try {
503:                    ushome = hero.interfaces.UserServiceUtil.getLocalHome();
504:                    UserServiceLocal ul = ushome.create();
505:                    Map infos = ul.getUserInfos(mContext.getCallerPrincipal()
506:                            .getName());
507:                    return ((String) infos.get("email"));
508:                } catch (Exception ce) {
509:                    trace.error(ce.getMessage());
510:                    throw new HeroException(ce.getMessage());
511:                }
512:            }
513:
514:            /**
515:             * Get the user password
516:             *
517:             * @return a String - get user password
518:             * @ejb:interface-method view-type="both"
519:             * @ejb:transaction type="Supports"
520:             **/
521:            public String getUserPassword() throws HeroException {
522:                UserServiceLocalHome ushome = null;
523:                try {
524:                    ushome = hero.interfaces.UserServiceUtil.getLocalHome();
525:                    UserServiceLocal ul = ushome.create();
526:                    Map infos = ul.getUserInfos(mContext.getCallerPrincipal()
527:                            .getName());
528:                    return ((String) infos.get("password"));
529:                } catch (Exception ce) {
530:                    trace.error(ce.getMessage());
531:                    throw new HeroException(ce.getMessage());
532:                }
533:            }
534:
535:            /**
536:             * Get the user jabber address
537:             *
538:             * @return a String - get user jabber address
539:             * @ejb:interface-method view-type="both"
540:             * @ejb:transaction type="Supports"
541:             **/
542:            public String getUserJabber() throws HeroException {
543:                UserServiceLocalHome ushome = null;
544:                try {
545:                    ushome = hero.interfaces.UserServiceUtil.getLocalHome();
546:                    UserServiceLocal ul = ushome.create();
547:                    Map infos = ul.getUserInfos(mContext.getCallerPrincipal()
548:                            .getName());
549:                    return ((String) infos.get("jabber"));
550:                } catch (Exception ce) {
551:                    trace.error(ce.getMessage());
552:                    throw new HeroException(ce.getMessage());
553:                }
554:            }
555:
556:            /**
557:             * Get User properties
558:             *
559:             * @return a BnUserPropertyValue Collection - list of user properties
560:             * @ejb:interface-method view-type="both"
561:             * @ejb:transaction type="Supports"
562:             *
563:             **/
564:            public String getUserProperties() throws HeroException {
565:                trace.debug("start by "
566:                        + mContext.getCallerPrincipal().getName());
567:                Collection prp = new ArrayList();
568:                BnUserPropertyLocal pl;
569:                UserProperties ub = new UserProperties();
570:                try {
571:                    BnUserLocalHome userhome = hero.interfaces.BnUserUtil
572:                            .getLocalHome();
573:                    BnUserLocal mUser = userhome.findByName(mContext
574:                            .getCallerPrincipal().getName());
575:                    Collection pls = mUser.getBnProperties();
576:
577:                    for (Iterator i = pls.iterator(); i.hasNext();) {
578:                        pl = (BnUserPropertyLocal) i.next();
579:                        prp.add(pl.getBnUserPropertyValue());
580:                    }
581:
582:                    try {
583:                        ub.setProperty(prp);
584:                        StringWriter sw = new StringWriter();
585:                        Marshaller.marshal(ub, sw);
586:                        return (sw.toString());
587:                    } catch (MarshalException ex1) {
588:                        throw new HeroException(ex1.getMessage());
589:                    } catch (ValidationException ex2) {
590:                        throw new HeroException(ex2.getMessage());
591:                    }
592:
593:                } catch (javax.naming.NamingException ne) {
594:                    throw new HeroException(ne.getMessage());
595:                } catch (javax.ejb.FinderException fe) {
596:                    throw new HeroException(mContext.getCallerPrincipal()
597:                            .getName()
598:                            + " does not exists");
599:                }
600:            }
601:
602:            /**
603:             * Create the BnUser Session Bean
604:             *
605:             * @throws CreateException 
606:             *
607:             * @ejb:create-method view-type="both"
608:             **/
609:            public void ejbCreate() throws CreateException {
610:            }
611:
612:            public void setSessionContext(final javax.ejb.SessionContext context) {
613:                mContext = context;
614:            }
615:
616:            public void ejbRemove() {
617:            }
618:
619:            public void ejbActivate() {
620:            }
621:
622:            public void ejbPassivate() {
623:            }
624:
625:            // utility methods
626:            private boolean checkRights(ProjectSessionLocal ps)
627:                    throws HeroException {
628:                // check that current user is a member of the project
629:                return ps.containsUser(mContext.getCallerPrincipal().getName());
630:            }
631:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.