KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > hero > session > ProjectSoapXMLBean


1 package hero.session;
2 /*
3  *
4  * ProjectSoapXMLBean.java -
5  * Copyright (C) 2003 Ecoo Team
6  * valdes@loria.fr
7  *
8  *
9  * This program is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public License
11  * as published by the Free Software Foundation; either version 2
12  * of the License, or (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22  */

23
24 import hero.interfaces.Constants;
25 import hero.interfaces.BnEdgeLocal;
26 import hero.interfaces.BnEdgeLocalHome;
27 import hero.interfaces.BnEdgeValue;
28 import hero.interfaces.BnNodeHookLocal;
29 import hero.interfaces.BnNodeHookValue;
30 import hero.interfaces.BnNodeInterHookLocal;
31 import hero.interfaces.BnNodeLightValue;
32 import hero.interfaces.BnNodeLocal;
33 import hero.interfaces.BnNodeLocalHome;
34 import hero.interfaces.BnNodePropertyLocal;
35 import hero.interfaces.BnNodePropertyValue;
36 import hero.interfaces.BnNodeValue;
37 import hero.interfaces.BnAgentEdgeLocal;
38 import hero.interfaces.BnAgentEdgeLocalHome;
39 import hero.interfaces.BnAgentEdgeValue;
40 import hero.interfaces.BnAgentLocal;
41 import hero.interfaces.BnAgentLocalHome;
42 import hero.interfaces.BnAgentValue;
43 import hero.interfaces.BnProjectHookLocal;
44 import hero.interfaces.BnProjectHookValue;
45 import hero.interfaces.BnProjectInterHookLocal;
46 import hero.interfaces.BnProjectLocal;
47 import hero.interfaces.BnProjectLocalHome;
48 import hero.interfaces.BnProjectPropertyLocal;
49 import hero.interfaces.BnProjectPropertyValue;
50 import hero.interfaces.BnProjectValue;
51 import hero.interfaces.BnRoleLocal;
52 import hero.interfaces.BnRoleLocalHome;
53 import hero.interfaces.BnRoleValue;
54 import hero.interfaces.BnUserLightValue;
55 import hero.interfaces.BnUserLocal;
56 import hero.interfaces.BnUserLocalHome;
57 import hero.interfaces.BnUserUtil;
58 import hero.util.EventConstants;
59 import hero.util.HeroException;
60 import hero.interfaces.JMSServicesSessionUtil;
61 import hero.interfaces.JMSServicesSessionLocalHome;
62 import hero.interfaces.JMSServicesSessionLocal;
63
64
65 import hero.util.BonitaConfig;
66 import hero.util.NodeHooks;
67 import hero.util.NodeInEdges;
68 import hero.util.NodeOutEdges;
69 import hero.util.NodeProperties;
70 import hero.util.ProjectHooks;
71 import hero.util.ProjectNodes;
72 import hero.util.ProjectProperties;
73 import hero.util.ProjectRoles;
74 import hero.util.ProjectUsers;
75 import java.io.StringWriter JavaDoc;
76 import java.rmi.RemoteException JavaDoc;
77 import java.util.ArrayList JavaDoc;
78 import java.util.Collection JavaDoc;
79 import java.util.Date JavaDoc;
80 import java.util.Iterator JavaDoc;
81
82 import javax.ejb.CreateException JavaDoc;
83 import javax.ejb.FinderException JavaDoc;
84 import javax.ejb.SessionBean JavaDoc;
85 import javax.ejb.SessionContext JavaDoc;
86 import javax.ejb.EJBException JavaDoc;
87 import javax.naming.Context JavaDoc;
88
89 import org.apache.log4j.Category;
90 import org.exolab.castor.xml.MarshalException;
91 import org.exolab.castor.xml.Marshaller;
92 import org.exolab.castor.xml.ValidationException;
93 import hero.util.StrutsNodeValue;
94
95
96 /**
97  * ProjectSessionXML API based on ProjectSession API but oriented to web services
98  * calls from a non-Java language. Get methods of this API returns
99  * XML.
100  *
101  * @ejb:bean name="ProjectSoapXML"
102  * display-name="ProjectSoapXML Bean"
103  * type="Stateful"
104  * transaction-type="Container"
105  * jndi-name="ejb/hero/ProjectSoapXML"
106  *
107  * @ejb:ejb-ref ejb-name="ProjectSoapXML"
108  * view-type="remote"
109  * ref-name="ProjectSoapXML"
110  *
111  * @ejb:ejb-ref ejb-name="BnProject"
112  * ref-name="myhero/BnProject"
113  *
114  * @ejb:transaction type="Supports"
115  * @ejb.permission role-name="BONITAUSER,user,SuperAdmin"
116  *
117  * @jonas.bean
118  * ejb-name="ProjectSoapXML"
119  * jndi-name="ejb/hero/ProjectSoapXML"
120  *
121  * @copyright INRIA
122  * @author Miguel Valdes
123  **/

124
125 public class ProjectSoapXMLBean implements SessionBean JavaDoc, EventConstants {
126     
127     // -------------------------------------------------------------------------
128
// Static
129
// -------------------------------------------------------------------------
130
// Utility variable
131
private static final Category trace = Category.getInstance(ProjectSoapXMLBean.class);
132     
133     // -------------------------------------------------------------------------
134
// Members
135
// -------------------------------------------------------------------------
136

137     private SessionContext JavaDoc mContext;
138     
139     private BnProjectLocalHome pHome;
140     private BnProjectLocal mProject;
141     private JMSServicesSessionLocal jms;
142     private Collection JavaDoc subProjects = new ArrayList JavaDoc();
143     private ArrayList JavaDoc visited = new ArrayList JavaDoc();
144     private BonitaConfig bonitaConfig;
145     
146     // -------------------------------------------------------------------------
147
// XML Get Methods (Castor Data Binding)
148
// -------------------------------------------------------------------------
149

150     /**
151      * Get ProjectName
152      * @return String
153      *
154      * @ejb:interface-method view-type="both"
155      * @ejb:transaction type="Supports"
156      *
157      **/

158     public String JavaDoc getName() throws HeroException {
159         if (this.getProjectConfigTrace())
160             trace.info("process name = " + this.getName()+ " started by " + mContext.getCallerPrincipal().getName());
161         return mProject.getName();
162     }
163     
164     /**
165      * Get project information
166      *
167      * @ejb:interface-method view-type="both"
168      * @ejb:transaction type="Supports"
169      *
170      **/

171     
172     public String JavaDoc getProjectDetails() throws HeroException {
173         if (this.getProjectConfigTrace())
174             trace.info("process name = " + this.getName()+ " started by " + mContext.getCallerPrincipal().getName());
175         try {
176             //BnProjectLightValue pl = mProject.getBnProjectLightValue();
177
BnProjectValue pl = mProject.getBnProjectValue();
178             StringWriter JavaDoc sw = new StringWriter JavaDoc();
179             Marshaller.marshal(pl, sw);
180             return (sw.toString());
181         } catch (MarshalException ex1) {
182             throw new HeroException(ex1.getMessage());
183         } catch (ValidationException ex2) {
184             throw new HeroException(ex2.getMessage());
185         }
186     }
187     
188     /**
189      * Get node information
190      *
191      * @ejb:interface-method view-type="both"
192      * @ejb:transaction type="Supports"
193      *
194      **/

195     
196     public String JavaDoc getNodeDetails(String JavaDoc node) throws HeroException {
197         if (this.getProjectConfigTrace())
198             trace.info(" Parameter: node=" + node + "process name = " + this.getName()+" started by " + mContext.getCallerPrincipal().getName());
199         try {
200             BnNodeLocal nd = mProject.getBnNode(node);
201             BnNodeLightValue nl = nd.getBnNodeLightValue();
202             
203             StringWriter JavaDoc sw = new StringWriter JavaDoc();
204             Marshaller.marshal(nl, sw);
205             return (sw.toString());
206         } catch (MarshalException ex1) {
207             throw new HeroException(ex1.getMessage());
208         } catch (ValidationException ex2) {
209             throw new HeroException(ex2.getMessage());
210         }
211     }
212     
213     /**
214      * Get the node Light Value
215      *
216      * @param name the name of the Node
217      *
218      * @ejb:interface-method view-type="both"
219      * @ejb:transaction type="Supports"
220      *
221      **/

222     public String JavaDoc getNodeLightValue(String JavaDoc name)
223     throws HeroException {
224         if (this.getProjectConfigTrace())
225             trace.info(" Parameter: name=" + name + "process name = " + this.getName()+" started by " + mContext.getCallerPrincipal().getName());
226         BnNodeLocalHome nHome;
227         BnNodeLocal mNode;
228         BnNodeLightValue nv;
229         try {
230             nHome = hero.interfaces.BnNodeUtil.getLocalHome();
231         } catch (javax.naming.NamingException JavaDoc be) {
232             throw new HeroException(be.getMessage());
233         }
234         try {
235             mNode = nHome.findByName(name, mProject.getId());
236             nv = mNode.getBnNodeLightValue();
237             StringWriter JavaDoc sw = new StringWriter JavaDoc();
238             Marshaller.marshal(nv, sw);
239             return (sw.toString());
240         } catch (MarshalException ex1) {
241             throw new HeroException(ex1.getMessage());
242         } catch (ValidationException ex2) {
243             throw new HeroException(ex2.getMessage());
244         } catch (FinderException JavaDoc fe) {
245             throw new HeroException("In BnNode does not exist");
246         }
247     }
248     
249     /**
250      * Get node deadline
251      * @return String
252      *
253      * @param nodeName The name of the node
254      *
255      * @ejb:interface-method view-type="both"
256      * @ejb:transaction type="Supports"
257      *
258      **/

259     public String JavaDoc getNodeDeadline(String JavaDoc nodeName) throws HeroException {
260         if (this.getProjectConfigTrace())
261             trace.info(" Parameter: nodeName=" + nodeName + "process name = " + this.getName()+" started by " + mContext.getCallerPrincipal().getName());
262         BnNodeLocal nd = mProject.getBnNode(nodeName);
263         /* modif MBL
264         if (nd.getDeadline() != null)
265             return (nd.getDeadline().toString());
266         */

267         if (nd.getDeadlines().size() != 0) {
268             Collection JavaDoc co = nd.getDeadlines();
269             Iterator JavaDoc it = co.iterator();
270             Date JavaDoc date = null;
271             while (it.hasNext()){
272                 date = (Date JavaDoc)it.next();
273             }
274             return(date.toString());
275          }
276         else
277             return (null);
278     }
279     
280     /**
281      * Get the node description
282      *
283      * @param name of the node
284      * @ejb:interface-method view-type="both"
285      * @ejb:transaction type="Supports"
286      *
287      **/

288     public String JavaDoc getNodeDescription(String JavaDoc name) throws HeroException {
289         if (this.getProjectConfigTrace())
290             trace.info(" Parameter: name=" + name + "process name = " + this.getName()+" started by " + mContext.getCallerPrincipal().getName());
291         BnNodeLocal nd = mProject.getBnNode(name);
292         return (nd.getDescription());
293     }
294     
295     /**
296      * Get node role information
297      *
298      * @ejb:interface-method view-type="both"
299      * @ejb:transaction type="Supports"
300      *
301      **/

302     
303     public String JavaDoc getNodeRole(String JavaDoc node) throws HeroException {
304         if (this.getProjectConfigTrace())
305             trace.info(" Parameter: node=" + node + "process name = " + this.getName()+" started by " + mContext.getCallerPrincipal().getName());
306         try {
307             BnNodeLocal nd = mProject.getBnNode(node);
308             BnRoleValue rl = ((BnRoleLocal) nd.getBnRole()).getBnRoleValue();
309             
310             StringWriter JavaDoc sw = new StringWriter JavaDoc();
311             Marshaller.marshal(rl, sw);
312             return (sw.toString());
313         } catch (MarshalException ex1) {
314             throw new HeroException(ex1.getMessage());
315         } catch (ValidationException ex2) {
316             throw new HeroException(ex2.getMessage());
317         }
318     }
319     
320     /**
321      * Get node role name
322      * @return String
323      *
324      * @param nodeName The name of the node
325      *
326      * @ejb:interface-method view-type="both"
327      * @ejb:transaction type="Supports"
328      *
329      **/

330     public String JavaDoc getNodeRoleName(String JavaDoc nodeName) throws HeroException {
331         if (this.getProjectConfigTrace())
332             trace.info(" Parameter: nodeName=" + nodeName+ "process name = " + this.getName()+" started by " + mContext.getCallerPrincipal().getName());
333         BnNodeLocal nd = mProject.getBnNode(nodeName);
334         return (((BnRoleLocal) nd.getBnRole()).getName());
335     }
336     
337     /**
338      * Get the Agent Value
339      *
340      * @param name the name of the BnAgent
341      *
342      * @ejb:interface-method view-type="both"
343      * @ejb:transaction type="Supports"
344      *
345      **/

346     public String JavaDoc getAgentValue(String JavaDoc name) throws HeroException {
347         if (this.getProjectConfigTrace())
348             trace.info(" Parameter: name=" + name+ "process name = " + this.getName()+" started by " + mContext.getCallerPrincipal().getName());
349         BnAgentLocalHome nHome;
350         BnAgentLocal mAgent;
351         BnAgentValue av;
352         try {
353             nHome = hero.interfaces.BnAgentUtil.getLocalHome();
354         } catch (javax.naming.NamingException JavaDoc be) {
355             throw new HeroException(be.getMessage());
356         }
357         try {
358             mAgent = nHome.findByName(name, mProject.getId());
359             av = mAgent.getBnAgentValue();
360             StringWriter JavaDoc sw = new StringWriter JavaDoc();
361             Marshaller.marshal(av, sw);
362             return (sw.toString());
363         } catch (FinderException JavaDoc fe) {
364             throw new HeroException("In Agent does not exist");
365         } catch (MarshalException ex1) {
366             throw new HeroException(ex1.getMessage());
367         } catch (ValidationException ex2) {
368             throw new HeroException(ex2.getMessage());
369         }
370     }
371     
372     /**
373      * Get the AgentEdge Value
374      *
375      * @param name the name of the AgentEdge
376      *
377      * @ejb:interface-method view-type="both"
378      * @ejb:transaction type="Supports"
379      *
380      **/

381     public String JavaDoc getAgentEdgeValue(String JavaDoc name)
382     throws HeroException {
383         if (this.getProjectConfigTrace())
384             trace.info(" Parameter: name=" + name+ "process name = " + this.getName()+" started by " + mContext.getCallerPrincipal().getName());
385         BnAgentEdgeLocalHome nHome;
386         BnAgentEdgeLocal mAgentEdge;
387         BnAgentEdgeValue av;
388         try {
389             nHome = hero.interfaces.BnAgentEdgeUtil.getLocalHome();
390         } catch (javax.naming.NamingException JavaDoc be) {
391             throw new HeroException(be.getMessage());
392         }
393         try {
394             mAgentEdge = nHome.findByName(name, mProject.getId());
395             av = mAgentEdge.getBnAgentEdgeValue();
396             StringWriter JavaDoc sw = new StringWriter JavaDoc();
397             Marshaller.marshal(av, sw);
398             return (sw.toString());
399         } catch (FinderException JavaDoc fe) {
400             throw new HeroException("In BnAgentEdge does not exist");
401         } catch (MarshalException ex1) {
402             throw new HeroException(ex1.getMessage());
403         } catch (ValidationException ex2) {
404             throw new HeroException(ex2.getMessage());
405         }
406     }
407     
408     
409     /**
410      * Get node executor information
411      *
412      * @ejb:interface-method view-type="both"
413      * @ejb:transaction type="Supports"
414      *
415      **/

416     
417     public String JavaDoc getNodeExecutor(String JavaDoc node) throws HeroException {
418         if (this.getProjectConfigTrace())
419             trace.info(" Parameter: node=" + node+ "process name = " + this.getName()+" started by " + mContext.getCallerPrincipal().getName());
420         BnUserLocalHome uHome;
421         BnUserLocal user;
422         try {
423             BnNodeLocal nd = mProject.getBnNode(node);
424             try {
425                 uHome = (BnUserLocalHome) hero.interfaces.BnUserUtil.getLocalHome();
426             } catch (javax.naming.NamingException JavaDoc be) {
427                 throw new HeroException(be.getMessage());
428             }
429             try {
430                 user = uHome.findByName(nd.getExecutor());
431             } catch (FinderException JavaDoc f) {
432                 throw new HeroException("FinderException");
433             }
434             BnUserLightValue ul = user.getBnUserLightValue();
435             
436             StringWriter JavaDoc sw = new StringWriter JavaDoc();
437             Marshaller.marshal(ul, sw);
438             return (sw.toString());
439         } catch (MarshalException ex1) {
440             throw new HeroException(ex1.getMessage());
441         } catch (ValidationException ex2) {
442             throw new HeroException(ex2.getMessage());
443         }
444     }
445     
446     /**
447      * Get the state of the node
448      *
449      * @param name of the node
450      * @return The state of the node
451      * @ejb:interface-method view-type="both"
452      * @ejb:transaction type="Supports"
453      *
454      **/

455     public int getNodeState(String JavaDoc name) throws HeroException {
456         if (this.getProjectConfigTrace())
457             trace.info(" Parameter: name=" + name+ "process name = " + this.getName()+" started by " + mContext.getCallerPrincipal().getName());
458         BnNodeLocal nd = mProject.getBnNode(name);
459         return (nd.getState());
460     }
461     
462     /**
463      * Get the type of the node
464      *
465      * @param name of the node
466      * @return The type of the node
467      * @ejb:interface-method view-type="both"
468      * @ejb:transaction type="Supports"
469      *
470      **/

471     public int getNodeType(String JavaDoc name) throws HeroException {
472         if (this.getProjectConfigTrace())
473             trace.info(" Parameter: name=" + name+ "process name = " + this.getName()+" started by " + mContext.getCallerPrincipal().getName());
474         BnNodeLocal nd = mProject.getBnNode(name);
475         return (nd.getType());
476     }
477     
478     /**
479      * Get the node Value
480      *
481      * @param name the name of the BnNode
482      *
483      * @ejb:interface-method view-type="both"
484      * @ejb:transaction type="Supports"
485      *
486      **/

487     public String JavaDoc getNodeValue(String JavaDoc name) throws HeroException {
488         if (this.getProjectConfigTrace())
489             trace.info(" Parameter: name=" + name+ "process name = " + this.getName()+" started by " + mContext.getCallerPrincipal().getName());
490         BnNodeLocalHome nHome;
491         BnNodeLocal mNode;
492         BnNodeValue nv;
493         try {
494             nHome = hero.interfaces.BnNodeUtil.getLocalHome();
495         } catch (javax.naming.NamingException JavaDoc be) {
496             throw new HeroException(be.getMessage());
497         }
498         try {
499             mNode = nHome.findByName(name, mProject.getId());
500             nv = mNode.getBnNodeValue();
501             StringWriter JavaDoc sw = new StringWriter JavaDoc();
502             Marshaller.marshal(nv, sw);
503             return (sw.toString());
504         } catch (MarshalException ex1) {
505             throw new HeroException(ex1.getMessage());
506         } catch (ValidationException ex2) {
507             throw new HeroException(ex2.getMessage());
508         } catch (FinderException JavaDoc fe) {
509             throw new HeroException("This Node does not exist");
510         }
511     }
512     
513     /**
514      * Get all nodes of this project
515      *
516      * @ejb:interface-method view-type="both"
517      * @ejb:transaction type="Supports"
518      *
519      **/

520     
521     public String JavaDoc getNodes() throws HeroException {
522         if (this.getProjectConfigTrace())
523             trace.info("process name = " + this.getName()+ " started by " + mContext.getCallerPrincipal().getName());
524         ProjectNodes nb = new ProjectNodes();
525         Collection JavaDoc nodes = new ArrayList JavaDoc();
526         ArrayList JavaDoc ns = new ArrayList JavaDoc();
527         StringWriter JavaDoc sw = new StringWriter JavaDoc();
528         
529         nodes = mProject.getBnNodes();
530         Iterator JavaDoc i = nodes.iterator();
531         while (i.hasNext()) {
532             BnNodeLocal n = (BnNodeLocal) i.next();
533             StrutsNodeValue snv = new StrutsNodeValue();
534             snv.setProjectName(mProject.getName());
535             snv.setName(n.getName());
536             snv.setCreator(n.getCreator());
537             snv.setRole(n.getBnRole().getName());
538             snv.setState(Constants.Nd.nodeStateName[n.getState()]);
539             snv.setType(Constants.Nd.nodeTypeName[n.getType()]);
540             if (n.getDescription() != null)
541                 snv.setDescription(n.getDescription());
542             if (n.getExecutor() != null)
543                 snv.setExecutor(n.getExecutor());
544             snv.setAnticipable(n.getAnticipable());
545             if (n.getDeadlines().size() != 0) {
546                 Collection JavaDoc co = n.getDeadlines();
547                 Iterator JavaDoc it = co.iterator();
548                 Date JavaDoc date = null;
549                 while (it.hasNext()){
550                     date = (Date JavaDoc)it.next();
551                 }
552                 snv.setDeadline(date.toString());
553              }
554             ns.add(snv);
555         }
556         nb.setNodes(ns.toArray());
557         
558         try {
559             Marshaller.marshal(nb, sw);
560         } catch (MarshalException e) {
561             e.printStackTrace();
562         } catch (ValidationException e) {
563             e.printStackTrace();
564         }
565         return (sw.toString());
566     }
567     
568     /**
569      * Get all node names of the project
570      *
571      * @ejb:interface-method view-type="both"
572      * @ejb:transaction type="Supports"
573      *
574      **/

575     public Collection JavaDoc getNodesNames() throws HeroException {
576         if (this.getProjectConfigTrace())
577             trace.info("process name = " + this.getName()+ " started by " + mContext.getCallerPrincipal().getName());
578         
579         // Vector names = new Vector();
580
ArrayList JavaDoc names = new ArrayList JavaDoc();
581         Collection JavaDoc nodes = mProject.getBnNodes();
582         Iterator JavaDoc i = nodes.iterator();
583         while (i.hasNext()) {
584             BnNodeLocal n = (BnNodeLocal) i.next();
585             names.add(n.getName());
586         }
587         return ((Collection JavaDoc) names);
588     }
589     
590     /**
591      * Get all users of this project
592      *
593      * @ejb:interface-method view-type="both"
594      * @ejb:transaction type="Supports"
595      *
596      **/

597     
598     public String JavaDoc getUsers() throws HeroException {
599         if (this.getProjectConfigTrace())
600             trace.info("process name = " + this.getName()+ " started by " + mContext.getCallerPrincipal().getName());
601         ProjectUsers ub = new ProjectUsers();
602         Collection JavaDoc us = new ArrayList JavaDoc();
603         
604         try {
605             Collection JavaDoc users = mProject.getBnUsers();
606             Iterator JavaDoc i = users.iterator();
607             while (i.hasNext()) {
608                 BnUserLocal u = (BnUserLocal) i.next();
609                 BnUserLightValue ul = u.getBnUserLightValue();
610                 us.add(ul);
611             }
612             ub.setUser(us);
613             StringWriter JavaDoc sw = new StringWriter JavaDoc();
614             Marshaller.marshal(ub, sw);
615             return (sw.toString());
616         } catch (MarshalException ex1) {
617             throw new HeroException(ex1.getMessage());
618         } catch (ValidationException ex2) {
619             throw new HeroException(ex2.getMessage());
620         }
621     }
622     
623     /**
624      * Get user roles in project names
625      * @return Collection
626      *
627      * @param userName The name of the user
628      *
629      * @ejb:interface-method view-type="both"
630      * @ejb:transaction type="Supports"
631      *
632      **/

633     public Collection JavaDoc getUserRolesInProjectNames(String JavaDoc userName)
634     throws HeroException {
635         if (this.getProjectConfigTrace())
636             trace.info(" Parameter: userName=" + userName+ "process name = " + this.getName()+" started by " + mContext.getCallerPrincipal().getName());
637         BnUserLocalHome uHome;
638         BnUserLocal user;
639         ArrayList JavaDoc result = new ArrayList JavaDoc();
640         try {
641             uHome = (BnUserLocalHome) hero.interfaces.BnUserUtil.getLocalHome();
642         } catch (javax.naming.NamingException JavaDoc be) {
643             throw new HeroException(be.getMessage());
644         }
645         try {
646             user = uHome.findByName(userName);
647         } catch (FinderException JavaDoc f) {
648             throw new HeroException("FinderException");
649         }
650         
651         Collection JavaDoc userRoles = user.getBnRoles();
652         Collection JavaDoc projectRoles = mProject.getBnRoles();
653         for (Iterator JavaDoc i = userRoles.iterator(); i.hasNext();) {
654             BnRoleLocal ur = (BnRoleLocal) i.next();
655             for (Iterator JavaDoc j = projectRoles.iterator(); j.hasNext();) {
656                 BnRoleLocal up = (BnRoleLocal) j.next();
657                 if (ur.getId().equals(up.getId()))
658                     result.add(ur.getBnRoleValue().getName());
659             }
660         }
661         return result;
662     }
663     
664     /**
665      * Get all roles of this project
666      *
667      * @ejb:interface-method view-type="both"
668      * @ejb:transaction type="Supports"
669      *
670      **/

671     
672     public String JavaDoc getRoles() throws HeroException {
673         if (this.getProjectConfigTrace())
674             trace.info("process name = " + this.getName()+ " started by " + mContext.getCallerPrincipal().getName());
675         ProjectRoles rb = new ProjectRoles();
676         Collection JavaDoc rs = new ArrayList JavaDoc();
677         
678         try {
679             Collection JavaDoc roles = mProject.getBnRoles();
680             Iterator JavaDoc i = roles.iterator();
681             while (i.hasNext()) {
682                 BnRoleLocal r = (BnRoleLocal) i.next();
683                 BnRoleValue rl = r.getBnRoleValue();
684                 rs.add(rl);
685             }
686             rb.setRole(rs);
687             StringWriter JavaDoc sw = new StringWriter JavaDoc();
688             Marshaller.marshal(rb, sw);
689             return (sw.toString());
690         } catch (MarshalException ex1) {
691             throw new HeroException(ex1.getMessage());
692         } catch (ValidationException ex2) {
693             throw new HeroException(ex2.getMessage());
694         }
695     }
696     
697     /**
698      * Get all roles names of the project
699      * @return Collection
700      *
701      * @ejb:interface-method view-type="both"
702      * @ejb:transaction type="Supports"
703      *
704      **/

705     public Collection JavaDoc getRolesNames() throws HeroException {
706         if (this.getProjectConfigTrace())
707             trace.info("process name = " + this.getName()+ " started by " + mContext.getCallerPrincipal().getName());
708         Collection JavaDoc roles = mProject.getBnRoles();
709         ArrayList JavaDoc result = new ArrayList JavaDoc();
710         for (Iterator JavaDoc i = roles.iterator(); i.hasNext();) {
711             result.add(((BnRoleLocal) i.next()).getName());
712         }
713         return result;
714     }
715     
716     /**
717      * Get user roles for this project
718      *
719      * @ejb:interface-method view-type="both"
720      * @ejb:transaction type="Supports"
721      *
722      **/

723     
724     public String JavaDoc getUserRoles(String JavaDoc userName) throws HeroException {
725         if (this.getProjectConfigTrace())
726             trace.info(" Parameter: userName=" + userName+ "process name = " + this.getName()+" started by " + mContext.getCallerPrincipal().getName());
727         BnUserLocalHome uHome;
728         BnUserLocal user;
729         Collection JavaDoc result = new ArrayList JavaDoc();
730         ProjectRoles rb = new ProjectRoles();
731         try {
732             uHome = (BnUserLocalHome) BnUserUtil.getLocalHome();
733         } catch (javax.naming.NamingException JavaDoc be) {
734             throw new HeroException(be.getMessage());
735         }
736         try {
737             user = uHome.findByName(userName);
738         } catch (FinderException JavaDoc f) {
739             throw new HeroException("FinderException");
740         }
741         Collection JavaDoc userRoles = user.getBnRoles();
742         Collection JavaDoc projectRoles = mProject.getBnRoles();
743         for (Iterator JavaDoc i = userRoles.iterator(); i.hasNext();) {
744             BnRoleLocal ur = (BnRoleLocal) i.next();
745             for (Iterator JavaDoc j = projectRoles.iterator(); j.hasNext();) {
746                 BnRoleLocal up = (BnRoleLocal) j.next();
747                 if (ur.getId() == up.getId())
748                     result.add(ur.getBnRoleValue());
749             }
750         }
751         try {
752             rb.setRole(result);
753             StringWriter JavaDoc sw = new StringWriter JavaDoc();
754             Marshaller.marshal(rb, sw);
755             return (sw.toString());
756         } catch (MarshalException ex1) {
757             throw new HeroException(ex1.getMessage());
758         } catch (ValidationException ex2) {
759             throw new HeroException(ex2.getMessage());
760         }
761     }
762     
763     /**
764      * Get user roles in project
765      * @return Collection
766      *
767      * @param userName The name of the user
768      *
769      * @ejb:interface-method view-type="both"
770      * @ejb:transaction type="Supports"
771      *
772      **/

773     public String JavaDoc getUserRolesInProject(String JavaDoc userName)
774     throws HeroException {
775         if (this.getProjectConfigTrace())
776             trace.info(" Parameter: userName=" + userName+ "process name = " + this.getName()+" started by " + mContext.getCallerPrincipal().getName());
777         BnUserLocalHome uHome;
778         BnUserLocal user;
779         ArrayList JavaDoc result = new ArrayList JavaDoc();
780         ProjectRoles rb = new ProjectRoles();
781         try {
782             uHome = (BnUserLocalHome) hero.interfaces.BnUserUtil.getLocalHome();
783         } catch (javax.naming.NamingException JavaDoc be) {
784             throw new HeroException(be.getMessage());
785         }
786         try {
787             user = uHome.findByName(userName);
788         } catch (FinderException JavaDoc f) {
789             throw new HeroException("FinderException");
790         }
791         Collection JavaDoc userRoles = user.getBnRoles();
792         Collection JavaDoc projectRoles = mProject.getBnRoles();
793         for (Iterator JavaDoc i = userRoles.iterator(); i.hasNext();) {
794             BnRoleLocal ur = (BnRoleLocal) i.next();
795             for (Iterator JavaDoc j = projectRoles.iterator(); j.hasNext();) {
796                 BnRoleLocal up = (BnRoleLocal) j.next();
797                 if (ur.getId() == up.getId())
798                     result.add(ur.getBnRoleValue());
799             }
800         }
801         try {
802             rb.setRole(result);
803             StringWriter JavaDoc sw = new StringWriter JavaDoc();
804             Marshaller.marshal(rb, sw);
805             return (sw.toString());
806         } catch (MarshalException ex1) {
807             throw new HeroException(ex1.getMessage());
808         } catch (ValidationException ex2) {
809             throw new HeroException(ex2.getMessage());
810         }
811     }
812     
813     
814     /**
815      * Get the properties of this project
816      *
817      * @ejb:interface-method view-type="both"
818      * @ejb:transaction type="Supports"
819      *
820      **/

821     
822     public String JavaDoc getProperties() throws HeroException {
823         if (this.getProjectConfigTrace())
824             trace.info("process name = " + this.getName()+ " started by " + mContext.getCallerPrincipal().getName());
825         ProjectProperties pb = new ProjectProperties();
826         Collection JavaDoc ps = new ArrayList JavaDoc();
827         
828         try {
829             Collection JavaDoc properties = mProject.getBnProperties();
830             Iterator JavaDoc i = properties.iterator();
831             while (i.hasNext()) {
832                 BnProjectPropertyLocal pp = (BnProjectPropertyLocal) i.next();
833                 BnProjectPropertyValue ppv = pp.getBnProjectPropertyValue();
834                 ps.add(ppv);
835             }
836             pb.setProperty(ps);
837             StringWriter JavaDoc sw = new StringWriter JavaDoc();
838             Marshaller.marshal(pb, sw);
839             return (sw.toString());
840         } catch (MarshalException ex1) {
841             throw new HeroException(ex1.getMessage());
842         } catch (ValidationException ex2) {
843             throw new HeroException(ex2.getMessage());
844         }
845     }
846     
847     /**
848      * Get the hooks of this project
849      *
850      * @ejb:interface-method view-type="both"
851      * @ejb:transaction type="Supports"
852      *
853      **/

854     
855     public String JavaDoc getHooks() throws HeroException {
856         if (this.getProjectConfigTrace())
857             trace.info("process name = " + this.getName()+ " started by " + mContext.getCallerPrincipal().getName());
858         ProjectHooks hb = new ProjectHooks();
859         Collection JavaDoc hs = new ArrayList JavaDoc();
860         
861         try {
862             Collection JavaDoc hooks = mProject.getBnHooks();
863             Iterator JavaDoc i = hooks.iterator();
864             while (i.hasNext()) {
865                 BnProjectHookLocal ph = (BnProjectHookLocal) i.next();
866                 BnProjectHookValue phv = ph.getBnProjectHookValue();
867                 hs.add(phv);
868             }
869             hb.setHook(hs);
870             StringWriter JavaDoc sw = new StringWriter JavaDoc();
871             Marshaller.marshal(hb, sw);
872             return (sw.toString());
873         } catch (MarshalException ex1) {
874             throw new HeroException(ex1.getMessage());
875         } catch (ValidationException ex2) {
876             throw new HeroException(ex2.getMessage());
877         }
878     }
879     
880     /**
881      * Get Interactive hooks of the project
882      *
883      * @return A BnProjectHookValue collection of all project inter hooks
884      * @ejb:interface-method view-type="both"
885      * @ejb:transaction type="Supports"
886      *
887      **/

888     public String JavaDoc getInterHooks() throws HeroException {
889         if (this.getProjectConfigTrace())
890             trace.info("process name = " + this.getName()+ " started by " + mContext.getCallerPrincipal().getName());
891         try{
892             Collection JavaDoc hk = new ArrayList JavaDoc();
893             ProjectHooks hb = new ProjectHooks();
894             BnProjectInterHookLocal pl;
895             Collection JavaDoc pls = mProject.getBnInterHooks();
896             
897             for (Iterator JavaDoc i = pls.iterator(); i.hasNext();) {
898                 pl = (BnProjectInterHookLocal) i.next();
899                 hk.add(pl.getBnProjectInterHookValue());
900             }
901             hb.setHook(hk);
902             StringWriter JavaDoc sw = new StringWriter JavaDoc();
903             Marshaller.marshal(hb, sw);
904             return (sw.toString());
905         } catch (MarshalException ex1) {
906             throw new HeroException(ex1.getMessage());
907         } catch (ValidationException ex2) {
908             throw new HeroException(ex2.getMessage());
909         }
910     }
911     
912     /**
913      * Get Interactive Node hooks of the project
914      *
915      * @param nodeName the name of the node
916      * @return A NodeHookValue collection of all node hooks (XML)
917      * @ejb:interface-method view-type="both"
918      * @ejb:transaction type="Supports"
919      *
920      **/

921     public String JavaDoc getNodeInterHooks(String JavaDoc nodeName) throws HeroException {
922         if (this.getProjectConfigTrace())
923             trace.info(" Parameter: nodeName=" + nodeName+ "process name = " + this.getName()+" started by " + mContext.getCallerPrincipal().getName());
924         try{
925             Collection JavaDoc hk = new ArrayList JavaDoc();
926             BnNodeInterHookLocal pl;
927             ProjectHooks hb = new ProjectHooks();
928             
929             BnNodeLocal nd = mProject.getBnNode(nodeName);
930             
931             Collection JavaDoc pls = nd.getBnInterHooks();
932             
933             for (Iterator JavaDoc i = pls.iterator(); i.hasNext();) {
934                 pl = (BnNodeInterHookLocal) i.next();
935                 hk.add(pl.getBnNodeInterHookValue());
936             }
937             hb.setHook(hk);
938             StringWriter JavaDoc sw = new StringWriter JavaDoc();
939             Marshaller.marshal(hb, sw);
940             return (sw.toString());
941         } catch (MarshalException ex1) {
942             throw new HeroException(ex1.getMessage());
943         } catch (ValidationException ex2) {
944             throw new HeroException(ex2.getMessage());
945         }
946     }
947     
948     /**
949      * Get the node hook value. Only for interactives hooks
950      *
951      * @param name of the node
952      * @param hook of the node
953      * @ejb:interface-method view-type="both"
954      * @ejb:transaction type="Supports"
955      *
956      **/

957     public String JavaDoc getNodeInterHookValue(String JavaDoc node, String JavaDoc hook)
958     throws HeroException {
959         if (this.getProjectConfigTrace())
960             trace.info(" Parameter: node=" + node+ " hook= "+hook+"process name = " + this.getName()+" started by " + mContext.getCallerPrincipal().getName());
961         String JavaDoc value = null;
962         BnNodeLocal nd = mProject.getBnNode(node);
963         Collection JavaDoc hooks = nd.getBnInterHooks();
964         for (Iterator JavaDoc ih = hooks.iterator(); ih.hasNext();) {
965             BnNodeInterHookLocal hk = (BnNodeInterHookLocal) ih.next();
966             if (hk.getName().equals(hook)) {
967                 value = hk.getScript();
968             }
969         }
970         return value;
971     }
972     
973     /**
974      * Get Node inter hook of the project
975      *
976      * @param nodeName the name of the node
977      * @param interHook name
978      * @return A BnNodeInterHookValue
979      * @ejb:interface-method view-type="both"
980      * @ejb:transaction type="Supports"
981      *
982      **/

983     public String JavaDoc getNodeInterHook(String JavaDoc nodeName, String JavaDoc interHook) throws HeroException {
984         if (this.getProjectConfigTrace())
985             trace.info(" Parameter: nodeName" + nodeName+ " interHook= "+interHook+"process name = " + this.getName()+" started by " + mContext.getCallerPrincipal().getName());
986         try{
987             BnNodeInterHookLocal hl;
988             BnNodeLocal nd = mProject.getBnNode(nodeName);
989             Collection JavaDoc hls = nd.getBnInterHooks();
990             
991             for (Iterator JavaDoc i = hls.iterator(); i.hasNext();) {
992                 hl = (BnNodeInterHookLocal) i.next();
993                 if (hl.getName().equals(interHook)) {
994                     StringWriter JavaDoc sw = new StringWriter JavaDoc();
995                     Marshaller.marshal(hl.getBnNodeInterHookValue(), sw);
996                     return (sw.toString());
997                 }
998             }
999         } catch (MarshalException ex1) {
1000            throw new HeroException(ex1.getMessage());
1001        } catch (ValidationException ex2) {
1002            throw new HeroException(ex2.getMessage());
1003        }
1004        return null;
1005    }
1006    
1007    /**
1008     * Return all registered users
1009     * @return A string collection of all user names
1010     *
1011     * @ejb:interface-method view-type="both"
1012     * @ejb:transaction type="Supports"
1013     *
1014     **/

1015    public Collection JavaDoc getAllUsers() throws HeroException {
1016        if (this.getProjectConfigTrace())
1017            trace.info("process name = " + this.getName()+ " started by " + mContext.getCallerPrincipal().getName());
1018        BnUserLocalHome uHome;
1019        Collection JavaDoc users;
1020        try {
1021            uHome = (BnUserLocalHome) hero.interfaces.BnUserUtil.getLocalHome();
1022        } catch (javax.naming.NamingException JavaDoc be) {
1023            throw new HeroException(be.getMessage());
1024        }
1025        try {
1026            users = uHome.findAll();
1027        } catch (FinderException JavaDoc f) {
1028            throw new HeroException("FinderException in findByAll users");
1029        }
1030        ArrayList JavaDoc result = new ArrayList JavaDoc();
1031        for (Iterator JavaDoc i = users.iterator(); i.hasNext();) {
1032            result.add(((BnUserLocal) i.next()).getName());
1033        }
1034        return result;
1035    }
1036    
1037    /**
1038     * Get the node properties of this project
1039     *
1040     * @ejb:interface-method view-type="both"
1041     * @ejb:transaction type="Supports"
1042     *
1043     **/

1044    
1045    public String JavaDoc getNodeProperties(String JavaDoc nodeName) throws HeroException {
1046        if (this.getProjectConfigTrace())
1047            trace.info(" Parameter: nodeName=" + nodeName+ "process name = " + this.getName()+" started by " + mContext.getCallerPrincipal().getName());
1048        NodeProperties nb = new NodeProperties();
1049        Collection JavaDoc ns = new ArrayList JavaDoc();
1050        
1051        try {
1052            BnNodeLocal nl = mProject.getBnNode(nodeName);
1053            Collection JavaDoc properties = nl.getBnProperties();
1054            Iterator JavaDoc i = properties.iterator();
1055            while (i.hasNext()) {
1056                BnNodePropertyLocal np = (BnNodePropertyLocal) i.next();
1057                BnNodePropertyValue npv = np.getBnNodePropertyValue();
1058                ns.add(npv);
1059            }
1060            nb.setProjectName(mProject.getName());
1061            nb.setProperty(ns);
1062            StringWriter JavaDoc sw = new StringWriter JavaDoc();
1063            Marshaller.marshal(nb, sw);
1064            return (sw.toString());
1065        } catch (MarshalException ex1) {
1066            throw new HeroException(ex1.getMessage());
1067        } catch (ValidationException ex2) {
1068            throw new HeroException(ex2.getMessage());
1069        }
1070    }
1071    
1072    /**
1073     * Get Node property of the project
1074     *
1075     * @param nodeName the name of the node
1076     * @param key Property key
1077     * @return A BnNodePropertyValue
1078     * @ejb:interface-method view-type="both"
1079     * @ejb:transaction type="Supports"
1080     *
1081     **/

1082    public String JavaDoc getNodeProperty(String JavaDoc nodeName, String JavaDoc key) throws HeroException {
1083        if (this.getProjectConfigTrace())
1084            trace.info(" Parameter: nodeName" + nodeName+ " key= "+key+"process name = " + this.getName()+" started by " + mContext.getCallerPrincipal().getName());
1085        try{
1086            BnNodePropertyLocal pl;
1087            BnNodeLocal nd = mProject.getBnNode(nodeName);
1088            Collection JavaDoc pls = nd.getBnProperties();
1089            
1090            for (Iterator JavaDoc i = pls.iterator(); i.hasNext();) {
1091                pl = (BnNodePropertyLocal) i.next();
1092                if (pl.getTheKey().equals(key)) {
1093                    StringWriter JavaDoc sw = new StringWriter JavaDoc();
1094                    Marshaller.marshal(pl.getBnNodePropertyValue(), sw);
1095                    return (sw.toString());
1096                }
1097            }
1098        } catch (MarshalException ex1) {
1099            throw new HeroException(ex1.getMessage());
1100        } catch (ValidationException ex2) {
1101            throw new HeroException(ex2.getMessage());
1102        }
1103        return (null);
1104    }
1105    
1106    /**
1107     * Get the node hooks of this project
1108     *
1109     * @ejb:interface-method view-type="both"
1110     * @ejb:transaction type="Supports"
1111     *
1112     **/

1113    
1114    public String JavaDoc getNodeHooks(String JavaDoc nodeName) throws HeroException {
1115        if (this.getProjectConfigTrace())
1116            trace.info(" Parameter: nodeName=" + nodeName+ "process name = " + this.getName()+" started by " + mContext.getCallerPrincipal().getName());
1117        NodeHooks nb = new NodeHooks();
1118        Collection JavaDoc hs = new ArrayList JavaDoc();
1119        
1120        try {
1121            BnNodeLocal nl = mProject.getBnNode(nodeName);
1122            Collection JavaDoc hooks = nl.getBnHooks();
1123            Iterator JavaDoc i = hooks.iterator();
1124            while (i.hasNext()) {
1125                BnNodeHookLocal nh = (BnNodeHookLocal) i.next();
1126                BnNodeHookValue nhv = nh.getBnNodeHookValue();
1127                hs.add(nhv);
1128            }
1129            nb.setProjectName(mProject.getName());
1130            nb.setHook(hs);
1131            StringWriter JavaDoc sw = new StringWriter JavaDoc();
1132            Marshaller.marshal(nb, sw);
1133            return (sw.toString());
1134        } catch (MarshalException ex1) {
1135            throw new HeroException(ex1.getMessage());
1136        } catch (ValidationException ex2) {
1137            throw new HeroException(ex2.getMessage());
1138        }
1139    }
1140    
1141    /**
1142     * Get creator of the project
1143     * @return String
1144     *
1145     * @ejb:interface-method view-type="both"
1146     * @ejb:transaction type="Supports"
1147     *
1148     **/

1149    public String JavaDoc getCreator() throws HeroException {
1150        if (this.getProjectConfigTrace())
1151            trace.info("process name = " + this.getName()+ " started by " + mContext.getCallerPrincipal().getName());
1152        return mProject.getCreator();
1153    }
1154    
1155    /**
1156     * get all in edges of the node
1157     * @return String
1158     *
1159     * @param name the name ot the node
1160     *
1161     * @ejb:interface-method view-type="both"
1162     * @ejb:transaction type="Supports"
1163     *
1164     **/

1165    public String JavaDoc getNodeInEdges(String JavaDoc name) throws HeroException {
1166        if (this.getProjectConfigTrace())
1167            trace.info(" Parameter: name=" + name+ "process name = " + this.getName()+" started by " + mContext.getCallerPrincipal().getName());
1168        NodeInEdges eb = new NodeInEdges();
1169        Collection JavaDoc in = new ArrayList JavaDoc();
1170        
1171        try {
1172            BnNodeLocal nd = mProject.getBnNode(name);
1173            
1174            Collection JavaDoc edgesIn = nd.getInBnEdges();
1175            Iterator JavaDoc i = edgesIn.iterator();
1176            while (i.hasNext())
1177                in.add(((BnEdgeLocal) i.next()).getBnEdgeValue());
1178            
1179            eb.setProjectName(mProject.getName());
1180            eb.setInEdge(in);
1181            StringWriter JavaDoc sw = new StringWriter JavaDoc();
1182            Marshaller.marshal(eb, sw);
1183            return (sw.toString());
1184        } catch (MarshalException ex1) {
1185            throw new HeroException(ex1.getMessage());
1186        } catch (ValidationException ex2) {
1187            throw new HeroException(ex2.getMessage());
1188        }
1189    }
1190    
1191    /**
1192     * Get the edge Condition
1193     *
1194     * @param edge name
1195     * @ejb:interface-method view-type="both"
1196     * @ejb:transaction type="Supports"
1197     *
1198     **/

1199    public String JavaDoc getEdgeCondition(String JavaDoc edge)
1200    throws HeroException {
1201        if (this.getProjectConfigTrace())
1202            trace.info(" Parameter: edge=" + edge+ "process name = " + this.getName()+" started by " + mContext.getCallerPrincipal().getName());
1203        BnEdgeLocal e = mProject.getBnEdge(edge);
1204        return(e.getCondition());
1205    }
1206    
1207    /**
1208     * Get edge in node
1209     * @return String
1210     *
1211     * @ejb:interface-method view-type="both"
1212     * @ejb:transaction type="Supports"
1213     *
1214     **/

1215    public String JavaDoc getEdgeInNode(String JavaDoc edgeName) throws HeroException {
1216        if (this.getProjectConfigTrace())
1217            trace.info(" Parameter: edgeName=" + edgeName+ "process name = " + this.getName()+" started by " + mContext.getCallerPrincipal().getName());
1218        BnEdgeLocal e = mProject.getBnEdge(edgeName);
1219        return (((BnNodeLocal) e.getInBnNode()).getName());
1220    }
1221    
1222    /**
1223     * Get edge out node
1224     * @return String
1225     *
1226     * @ejb:interface-method view-type="both"
1227     * @ejb:transaction type="Supports"
1228     *
1229     **/

1230    public String JavaDoc getEdgeOutNode(String JavaDoc edgeName) throws HeroException {
1231        if (this.getProjectConfigTrace())
1232            trace.info(" Parameter: edgeName=" + edgeName+ "process name = " + this.getName()+" started by " + mContext.getCallerPrincipal().getName());
1233        BnEdgeLocal e = mProject.getBnEdge(edgeName);
1234        return (((BnNodeLocal) e.getOutBnNode()).getName());
1235    }
1236    
1237    /**
1238     * Get all edges of the project
1239     * @return Collection
1240     *
1241     * @ejb:interface-method view-type="both"
1242     * @ejb:transaction type="Supports"
1243     *
1244     **/

1245    public Collection JavaDoc getEdgesNames() throws HeroException {
1246        if (this.getProjectConfigTrace())
1247            trace.info("process name = " + this.getName()+ " started by " + mContext.getCallerPrincipal().getName());
1248        // Vector names = new Vector();
1249
ArrayList JavaDoc names = new ArrayList JavaDoc();
1250        Collection JavaDoc edges = mProject.getBnEdges();
1251        Iterator JavaDoc i = edges.iterator();
1252        while (i.hasNext()) {
1253            BnEdgeLocal n = (BnEdgeLocal) i.next();
1254            names.add(n.getName());
1255        }
1256        return ((Collection JavaDoc) names);
1257    }
1258    
1259    /**
1260     * get all out edges of the node
1261     * @return Collection
1262     *
1263     * @param name the name ot the node
1264     *
1265     * @ejb:interface-method view-type="both"
1266     * @ejb:transaction type="Supports"
1267     *
1268     **/

1269    public String JavaDoc getNodeOutEdges(String JavaDoc name) throws HeroException {
1270        if (this.getProjectConfigTrace())
1271            trace.info(" Parameter: name=" + name+ "process name = " + this.getName()+" started by " + mContext.getCallerPrincipal().getName());
1272        NodeOutEdges eb = new NodeOutEdges();
1273        Collection JavaDoc out = new ArrayList JavaDoc();
1274        
1275        try {
1276            BnNodeLocal nd = mProject.getBnNode(name);
1277            
1278            Collection JavaDoc edgesOut = nd.getOutBnEdges();
1279            Iterator JavaDoc i = edgesOut.iterator();
1280            while (i.hasNext())
1281                out.add(((BnEdgeLocal) i.next()).getBnEdgeValue());
1282            
1283            eb.setProjectName(mProject.getName());
1284            eb.setOutEdge(out);
1285            StringWriter JavaDoc sw = new StringWriter JavaDoc();
1286            Marshaller.marshal(eb, sw);
1287            return (sw.toString());
1288        } catch (MarshalException ex1) {
1289            throw new HeroException(ex1.getMessage());
1290        } catch (ValidationException ex2) {
1291            throw new HeroException(ex2.getMessage());
1292        }
1293    }
1294    
1295    /**
1296     * Get the Edge Value
1297     *
1298     * @param name the name of the Edge
1299     *
1300     * @ejb:interface-method view-type="both"
1301     * @ejb:transaction type="Supports"
1302     *
1303     **/

1304    public String JavaDoc getEdgeValue(String JavaDoc name) throws HeroException {
1305        if (this.getProjectConfigTrace())
1306            trace.info(" Parameter: name=" + name+ "process name = " + this.getName()+" started by " + mContext.getCallerPrincipal().getName());
1307        BnEdgeLocalHome eHome;
1308        BnEdgeLocal mEdge;
1309        BnEdgeValue ev;
1310        try {
1311            eHome = hero.interfaces.BnEdgeUtil.getLocalHome();
1312        } catch (javax.naming.NamingException JavaDoc be) {
1313            throw new HeroException(be.getMessage());
1314        }
1315        try {
1316            mEdge = eHome.findByName(name, mProject.getId());
1317            ev = mEdge.getBnEdgeValue();
1318            StringWriter JavaDoc sw = new StringWriter JavaDoc();
1319            Marshaller.marshal(ev, sw);
1320            return (sw.toString());
1321        } catch (MarshalException ex1) {
1322            throw new HeroException(ex1.getMessage());
1323        } catch (ValidationException ex2) {
1324            throw new HeroException(ex2.getMessage());
1325        } catch (FinderException JavaDoc fe) {
1326            throw new HeroException("BnEdge does not exist");
1327        }
1328    }
1329    
1330    /**
1331     * Get the node in traditional mode
1332     *
1333     * @param name of the node
1334     * @ejb:interface-method view-type="both"
1335     * @ejb:transaction type="Required"
1336     *
1337     **/

1338    public boolean getNodeAnticipable(String JavaDoc name) throws HeroException {
1339        if (this.getProjectConfigTrace())
1340            trace.info(" Parameter: name=" + name+ "process name = " + this.getName()+" started by " + mContext.getCallerPrincipal().getName());
1341        BnNodeLocal nd = mProject.getBnNode(name);
1342        return (nd.getAnticipable());
1343    }
1344    
1345    /**
1346     * Get the inter hook value script
1347     *
1348     * @param script of the inter hook
1349     * @ejb:interface-method view-type="both"
1350     * @ejb:transaction type="Supports"
1351     *
1352     **/

1353    public String JavaDoc getInterHookValue(String JavaDoc hook) throws HeroException {
1354        String JavaDoc value= null;
1355        if (this.getProjectConfigTrace())
1356            trace.info(" Parameter: hook=" + hook+ "process name = " + this.getName()+" started by " + mContext.getCallerPrincipal().getName());
1357        Collection JavaDoc hooks = mProject.getBnInterHooks();
1358        for (Iterator JavaDoc ih = hooks.iterator(); ih.hasNext();) {
1359            BnProjectInterHookLocal hk = (BnProjectInterHookLocal) ih.next();
1360            if (hk.getName().equals(hook)) {
1361                value=hk.getScript();
1362            }
1363        }
1364        return value;
1365    }
1366    
1367    /**
1368     * Get the project name of this instance
1369     *
1370     * @param instanceName the name of the instance
1371     * @ejb:interface-method view-type="both"
1372     * @ejb:transaction type="Supports"
1373     *
1374     **/

1375    public String JavaDoc getProjectNameOfInstance(String JavaDoc instanceName) throws HeroException {
1376        if (this.getProjectConfigTrace())
1377            trace.info(" Parameter: instanceName=" + instanceName+ "process name = " + this.getName()+" started by " + mContext.getCallerPrincipal().getName());
1378        if (instanceName.matches(".*"+"_instance"+".*")){
1379            int i = instanceName.indexOf("_instance");
1380            return(instanceName.substring(0,i));
1381        }
1382        else
1383            throw new HeroException(instanceName+" is not a project instance...");
1384    }
1385    
1386    /**
1387     * Init the Project Session Bean. You have to call this method after "create" call. After that
1388     * all methods of ProjectSession API are available.
1389     *
1390     * @param projectName project name
1391     * @ejb:interface-method view-type="both"
1392     * @ejb:transaction type="Required"
1393     * @throws HeroException
1394     **/

1395    public void initProject(String JavaDoc projectName) throws HeroException {
1396        if (this.getProjectConfigTrace())
1397            trace.info(" Parameter: projectName=" + projectName+ " started by " + mContext.getCallerPrincipal().getName());
1398        Context JavaDoc lContext;
1399        BnUserLocalHome uhome = null;
1400        BnRoleLocalHome rhome = null;
1401        try {
1402            pHome = hero.interfaces.BnProjectUtil.getLocalHome();
1403            this.mProject = pHome.findByName(projectName);
1404        } catch (javax.naming.NamingException JavaDoc ne) {
1405            throw new HeroException(ne.getMessage());
1406        } catch (javax.ejb.FinderException JavaDoc fe) {
1407            throw new HeroException(fe.getMessage());
1408        }
1409    }
1410    
1411    private boolean getProjectConfigTrace() throws HeroException{
1412        if (this.getName()!=null)
1413            return (bonitaConfig.getProcessTrace(this.getName()));
1414        else
1415            return true;
1416    }
1417    
1418    /**
1419     * Creates the Project Session Bean. This method is the first one to invoke in order to
1420     * use ProjectSession API. If the user is not authorized this method throws an exception.
1421     *
1422     * @throws CreateException
1423     *
1424     * @ejb:create-method view-type="both"
1425     **/

1426    public void ejbCreate() throws CreateException JavaDoc {
1427    }
1428    
1429    /**
1430     * Internal Enterprise Java Beans method.
1431     **/

1432    public void ejbPostCreate(String JavaDoc oldProject, String JavaDoc newProject)
1433    throws CreateException JavaDoc, RemoteException JavaDoc {
1434    }
1435    
1436    /**
1437     * Internal Enterprise Java Beans method.
1438     **/

1439    public void setSessionContext(final javax.ejb.SessionContext JavaDoc context) {
1440        mContext = context;
1441        try{
1442            JMSServicesSessionLocalHome home = JMSServicesSessionUtil.getLocalHome();
1443            this.jms=home.create();
1444            this.bonitaConfig = new BonitaConfig();
1445        }catch(Exception JavaDoc e){throw new EJBException JavaDoc(e.getMessage());}
1446    }
1447    
1448    /**
1449     * Internal Enterprise Java Beans method.
1450     **/

1451    
1452    public void ejbRemove() {
1453    }
1454    
1455    /**
1456     * Internal Enterprise Java Beans method.
1457     **/

1458    
1459    public void ejbActivate() {
1460    }
1461    
1462    /**
1463     * Internal Enterprise Java Beans method.
1464     **/

1465    
1466    public void ejbPassivate() {
1467    }
1468    
1469}
1470
1471
Popular Tags