Source Code Cross Referenced for ProjectSoapXMLBean.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) 


0001:        package hero.session;
0002:
0003:        /*
0004:         *
0005:         * ProjectSoapXMLBean.java - 
0006:         * Copyright (C) 2003 Ecoo Team
0007:         * valdes@loria.fr
0008:         *
0009:         *
0010:         * This program is free software; you can redistribute it and/or
0011:         * modify it under the terms of the GNU Lesser General Public License
0012:         * as published by the Free Software Foundation; either version 2
0013:         * of the License, or (at your option) any later version.
0014:         *
0015:         * This program is distributed in the hope that it will be useful,
0016:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
0017:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0018:         * GNU Lesser General Public License for more details.
0019:         *
0020:         * You should have received a copy of the GNU Lesser General Public License
0021:         * along with this program; if not, write to the Free Software
0022:         * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
0023:         */
0024:
0025:        import hero.interfaces.Constants;
0026:        import hero.interfaces.BnEdgeLocal;
0027:        import hero.interfaces.BnEdgeLocalHome;
0028:        import hero.interfaces.BnEdgeValue;
0029:        import hero.interfaces.BnNodeHookLocal;
0030:        import hero.interfaces.BnNodeHookValue;
0031:        import hero.interfaces.BnNodeInterHookLocal;
0032:        import hero.interfaces.BnNodeLightValue;
0033:        import hero.interfaces.BnNodeLocal;
0034:        import hero.interfaces.BnNodeLocalHome;
0035:        import hero.interfaces.BnNodePropertyLocal;
0036:        import hero.interfaces.BnNodePropertyValue;
0037:        import hero.interfaces.BnNodeValue;
0038:        import hero.interfaces.BnAgentEdgeLocal;
0039:        import hero.interfaces.BnAgentEdgeLocalHome;
0040:        import hero.interfaces.BnAgentEdgeValue;
0041:        import hero.interfaces.BnAgentLocal;
0042:        import hero.interfaces.BnAgentLocalHome;
0043:        import hero.interfaces.BnAgentValue;
0044:        import hero.interfaces.BnProjectHookLocal;
0045:        import hero.interfaces.BnProjectHookValue;
0046:        import hero.interfaces.BnProjectInterHookLocal;
0047:        import hero.interfaces.BnProjectLocal;
0048:        import hero.interfaces.BnProjectLocalHome;
0049:        import hero.interfaces.BnProjectPropertyLocal;
0050:        import hero.interfaces.BnProjectPropertyValue;
0051:        import hero.interfaces.BnProjectValue;
0052:        import hero.interfaces.BnRoleLocal;
0053:        import hero.interfaces.BnRoleLocalHome;
0054:        import hero.interfaces.BnRoleValue;
0055:        import hero.interfaces.BnUserLightValue;
0056:        import hero.interfaces.BnUserLocal;
0057:        import hero.interfaces.BnUserLocalHome;
0058:        import hero.interfaces.BnUserUtil;
0059:        import hero.util.EventConstants;
0060:        import hero.util.HeroException;
0061:
0062:        import hero.util.NodeHooks;
0063:        import hero.util.NodeInEdges;
0064:        import hero.util.NodeOutEdges;
0065:        import hero.util.NodeProperties;
0066:        import hero.util.ProjectHooks;
0067:        import hero.util.ProjectNodes;
0068:        import hero.util.ProjectProperties;
0069:        import hero.util.ProjectRoles;
0070:        import hero.util.ProjectUsers;
0071:        import java.io.StringWriter;
0072:        import java.rmi.RemoteException;
0073:        import java.util.ArrayList;
0074:        import java.util.Collection;
0075:        import java.util.Date;
0076:        import java.util.Iterator;
0077:
0078:        import javax.ejb.CreateException;
0079:        import javax.ejb.FinderException;
0080:        import javax.ejb.SessionBean;
0081:        import javax.ejb.SessionContext;
0082:        import javax.ejb.EJBException;
0083:        import javax.naming.Context;
0084:
0085:        import org.apache.log4j.Category;
0086:        import org.exolab.castor.xml.MarshalException;
0087:        import org.exolab.castor.xml.Marshaller;
0088:        import org.exolab.castor.xml.ValidationException;
0089:        import hero.util.StrutsNodeValue;
0090:
0091:        /**
0092:         * ProjectSessionXML API based on ProjectSession API but oriented to web services 
0093:         * calls from a non-Java language. Get methods of this API returns
0094:         * XML.
0095:         *
0096:         * @ejb:bean name="ProjectSoapXML"
0097:         *           display-name="ProjectSoapXML Bean"
0098:         *           type="Stateful"
0099:         *           transaction-type="Container"
0100:         *           jndi-name="ejb/hero/ProjectSoapXML"
0101:         *
0102:         * @ejb:ejb-ref	ejb-name="ProjectSoapXML"
0103:         *              	view-type="remote"
0104:         *              	ref-name="ProjectSoapXML"
0105:         *
0106:         * @ejb:ejb-ref ejb-name="BnProject"
0107:         *              ref-name="myhero/BnProject"
0108:         *
0109:         * @ejb:transaction type="Supports"
0110:         * @ejb.permission role-name="BONITAUSER,user,SuperAdmin"
0111:         * 
0112:         * @jonas.bean
0113:         *      ejb-name="ProjectSoapXML"
0114:         *      jndi-name="ejb/hero/ProjectSoapXML"
0115:
0116:         * @jboss.container-configuration name="Standard Stateful SessionBean for Bonita"
0117:         * 
0118:         * @copyright INRIA
0119:         * @author Miguel Valdes
0120:         **/
0121:
0122:        public class ProjectSoapXMLBean implements  SessionBean, EventConstants {
0123:
0124:            // -------------------------------------------------------------------------
0125:            // Static
0126:            // -------------------------------------------------------------------------
0127:            // Utility variable
0128:            private static final Category trace = Category
0129:                    .getInstance(ProjectSoapXMLBean.class);
0130:
0131:            // -------------------------------------------------------------------------
0132:            // Members 
0133:            // -------------------------------------------------------------------------
0134:
0135:            private SessionContext mContext;
0136:
0137:            private BnProjectLocalHome pHome;
0138:            private BnProjectLocal mProject;
0139:            private Collection subProjects = new ArrayList();
0140:            private ArrayList visited = new ArrayList();
0141:
0142:            // -------------------------------------------------------------------------
0143:            // XML Get Methods (Castor Data Binding)
0144:            // -------------------------------------------------------------------------
0145:
0146:            /**
0147:             * Get ProjectName
0148:             * @return String 
0149:             *
0150:             * @ejb:interface-method view-type="both"
0151:             * @ejb:transaction type="Supports"
0152:             *
0153:             **/
0154:            public String getName() throws HeroException {
0155:
0156:                trace.debug("process name = " + this .getName() + " started by "
0157:                        + mContext.getCallerPrincipal().getName());
0158:                return mProject.getName();
0159:            }
0160:
0161:            /**
0162:             * Get project information
0163:             *
0164:             * @ejb:interface-method view-type="both"
0165:             * @ejb:transaction type="Supports"
0166:             *
0167:             **/
0168:
0169:            public String getProjectDetails() throws HeroException {
0170:
0171:                trace.debug("process name = " + this .getName() + " started by "
0172:                        + mContext.getCallerPrincipal().getName());
0173:                try {
0174:                    //BnProjectLightValue pl = mProject.getBnProjectLightValue();
0175:                    BnProjectValue pl = mProject.getBnProjectValue();
0176:                    StringWriter sw = new StringWriter();
0177:                    Marshaller.marshal(pl, sw);
0178:                    return (sw.toString());
0179:                } catch (MarshalException ex1) {
0180:                    throw new HeroException(ex1.getMessage());
0181:                } catch (ValidationException ex2) {
0182:                    throw new HeroException(ex2.getMessage());
0183:                }
0184:            }
0185:
0186:            /**
0187:             * Get node information
0188:             *
0189:             * @ejb:interface-method view-type="both"
0190:             * @ejb:transaction type="Supports"
0191:             *
0192:             **/
0193:
0194:            public String getNodeDetails(String node) throws HeroException {
0195:
0196:                trace.debug(" Parameter: node=" + node + "process name = "
0197:                        + this .getName() + " started by "
0198:                        + mContext.getCallerPrincipal().getName());
0199:                try {
0200:                    BnNodeLocal nd = mProject.getBnNode(node);
0201:                    BnNodeLightValue nl = nd.getBnNodeLightValue();
0202:
0203:                    StringWriter sw = new StringWriter();
0204:                    Marshaller.marshal(nl, sw);
0205:                    return (sw.toString());
0206:                } catch (MarshalException ex1) {
0207:                    throw new HeroException(ex1.getMessage());
0208:                } catch (ValidationException ex2) {
0209:                    throw new HeroException(ex2.getMessage());
0210:                }
0211:            }
0212:
0213:            /**
0214:             * Get the node Light Value
0215:             *
0216:             * @param name the name of the Node
0217:             *
0218:             * @ejb:interface-method view-type="both"
0219:             * @ejb:transaction type="Supports"
0220:             *
0221:             **/
0222:            public String getNodeLightValue(String name) throws HeroException {
0223:
0224:                trace.debug(" Parameter: name=" + name + "process name = "
0225:                        + this .getName() + " started by "
0226:                        + mContext.getCallerPrincipal().getName());
0227:                BnNodeLocalHome nHome;
0228:                BnNodeLocal mNode;
0229:                BnNodeLightValue nv;
0230:                try {
0231:                    nHome = hero.interfaces.BnNodeUtil.getLocalHome();
0232:                } catch (javax.naming.NamingException be) {
0233:                    throw new HeroException(be.getMessage());
0234:                }
0235:                try {
0236:                    mNode = nHome.findByName(name, mProject.getId());
0237:                    nv = mNode.getBnNodeLightValue();
0238:                    StringWriter sw = new StringWriter();
0239:                    Marshaller.marshal(nv, sw);
0240:                    return (sw.toString());
0241:                } catch (MarshalException ex1) {
0242:                    throw new HeroException(ex1.getMessage());
0243:                } catch (ValidationException ex2) {
0244:                    throw new HeroException(ex2.getMessage());
0245:                } catch (FinderException fe) {
0246:                    throw new HeroException("In BnNode does not exist");
0247:                }
0248:            }
0249:
0250:            /**
0251:             * Get node deadline
0252:             * @return String 
0253:             *
0254:             * @param nodeName The name of the node
0255:             *
0256:             * @ejb:interface-method view-type="both"
0257:             * @ejb:transaction type="Supports"
0258:             *
0259:             **/
0260:            public String getNodeDeadline(String nodeName) throws HeroException {
0261:
0262:                trace.debug(" Parameter: nodeName=" + nodeName
0263:                        + "process name = " + this .getName() + " started by "
0264:                        + mContext.getCallerPrincipal().getName());
0265:                BnNodeLocal nd = mProject.getBnNode(nodeName);
0266:                /* modif MBL
0267:                if (nd.getDeadline() != null)
0268:                	return (nd.getDeadline().toString());
0269:                 */
0270:                if (nd.getDeadlines().size() != 0) {
0271:                    Collection co = nd.getDeadlines();
0272:                    Iterator it = co.iterator();
0273:                    Date date = null;
0274:                    while (it.hasNext()) {
0275:                        date = (Date) it.next();
0276:                    }
0277:                    return (date.toString());
0278:                } else
0279:                    return (null);
0280:            }
0281:
0282:            /**
0283:             * Get the node description
0284:             *
0285:             * @param name of the node
0286:             * @ejb:interface-method view-type="both"
0287:             * @ejb:transaction type="Supports"
0288:             *
0289:             **/
0290:            public String getNodeDescription(String name) throws HeroException {
0291:
0292:                trace.debug(" Parameter: name=" + name + "process name = "
0293:                        + this .getName() + " started by "
0294:                        + mContext.getCallerPrincipal().getName());
0295:                BnNodeLocal nd = mProject.getBnNode(name);
0296:                return (nd.getDescription());
0297:            }
0298:
0299:            /**
0300:             * Get node role information
0301:             *
0302:             * @ejb:interface-method view-type="both"
0303:             * @ejb:transaction type="Supports"
0304:             *
0305:             **/
0306:
0307:            public String getNodeRole(String node) throws HeroException {
0308:
0309:                trace.debug(" Parameter: node=" + node + "process name = "
0310:                        + this .getName() + " started by "
0311:                        + mContext.getCallerPrincipal().getName());
0312:                try {
0313:                    BnNodeLocal nd = mProject.getBnNode(node);
0314:                    BnRoleValue rl = ((BnRoleLocal) nd.getBnRole())
0315:                            .getBnRoleValue();
0316:
0317:                    StringWriter sw = new StringWriter();
0318:                    Marshaller.marshal(rl, sw);
0319:                    return (sw.toString());
0320:                } catch (MarshalException ex1) {
0321:                    throw new HeroException(ex1.getMessage());
0322:                } catch (ValidationException ex2) {
0323:                    throw new HeroException(ex2.getMessage());
0324:                }
0325:            }
0326:
0327:            /**
0328:             * Get node role name
0329:             * @return String
0330:             *
0331:             * @param nodeName The name of the node
0332:             *
0333:             * @ejb:interface-method view-type="both"
0334:             * @ejb:transaction type="Supports"
0335:             *
0336:             **/
0337:            public String getNodeRoleName(String nodeName) throws HeroException {
0338:
0339:                trace.debug(" Parameter: nodeName=" + nodeName
0340:                        + "process name = " + this .getName() + " started by "
0341:                        + mContext.getCallerPrincipal().getName());
0342:                BnNodeLocal nd = mProject.getBnNode(nodeName);
0343:                return (((BnRoleLocal) nd.getBnRole()).getName());
0344:            }
0345:
0346:            /**
0347:             * Get the Agent Value
0348:             *
0349:             * @param name the name of the BnAgent
0350:             *
0351:             * @ejb:interface-method view-type="both"
0352:             * @ejb:transaction type="Supports"
0353:             *
0354:             **/
0355:            public String getAgentValue(String name) throws HeroException {
0356:
0357:                trace.debug(" Parameter: name=" + name + "process name = "
0358:                        + this .getName() + " started by "
0359:                        + mContext.getCallerPrincipal().getName());
0360:                BnAgentLocalHome nHome;
0361:                BnAgentLocal mAgent;
0362:                BnAgentValue av;
0363:                try {
0364:                    nHome = hero.interfaces.BnAgentUtil.getLocalHome();
0365:                } catch (javax.naming.NamingException be) {
0366:                    throw new HeroException(be.getMessage());
0367:                }
0368:                try {
0369:                    mAgent = nHome.findByName(name, mProject.getId());
0370:                    av = mAgent.getBnAgentValue();
0371:                    StringWriter sw = new StringWriter();
0372:                    Marshaller.marshal(av, sw);
0373:                    return (sw.toString());
0374:                } catch (FinderException fe) {
0375:                    throw new HeroException("In Agent does not exist");
0376:                } catch (MarshalException ex1) {
0377:                    throw new HeroException(ex1.getMessage());
0378:                } catch (ValidationException ex2) {
0379:                    throw new HeroException(ex2.getMessage());
0380:                }
0381:            }
0382:
0383:            /**
0384:             * Get the AgentEdge Value
0385:             *
0386:             * @param name the name of the AgentEdge
0387:             *
0388:             * @ejb:interface-method view-type="both"
0389:             * @ejb:transaction type="Supports"
0390:             *
0391:             **/
0392:            public String getAgentEdgeValue(String name) throws HeroException {
0393:
0394:                trace.debug(" Parameter: name=" + name + "process name = "
0395:                        + this .getName() + " started by "
0396:                        + mContext.getCallerPrincipal().getName());
0397:                BnAgentEdgeLocalHome nHome;
0398:                BnAgentEdgeLocal mAgentEdge;
0399:                BnAgentEdgeValue av;
0400:                try {
0401:                    nHome = hero.interfaces.BnAgentEdgeUtil.getLocalHome();
0402:                } catch (javax.naming.NamingException be) {
0403:                    throw new HeroException(be.getMessage());
0404:                }
0405:                try {
0406:                    mAgentEdge = nHome.findByName(name, mProject.getId());
0407:                    av = mAgentEdge.getBnAgentEdgeValue();
0408:                    StringWriter sw = new StringWriter();
0409:                    Marshaller.marshal(av, sw);
0410:                    return (sw.toString());
0411:                } catch (FinderException fe) {
0412:                    throw new HeroException("In BnAgentEdge does not exist");
0413:                } catch (MarshalException ex1) {
0414:                    throw new HeroException(ex1.getMessage());
0415:                } catch (ValidationException ex2) {
0416:                    throw new HeroException(ex2.getMessage());
0417:                }
0418:            }
0419:
0420:            /**
0421:             * Get node executor information
0422:             *
0423:             * @ejb:interface-method view-type="both"
0424:             * @ejb:transaction type="Supports"
0425:             *
0426:             **/
0427:
0428:            public String getNodeExecutor(String node) throws HeroException {
0429:
0430:                trace.debug(" Parameter: node=" + node + "process name = "
0431:                        + this .getName() + " started by "
0432:                        + mContext.getCallerPrincipal().getName());
0433:                BnUserLocalHome uHome;
0434:                BnUserLocal user;
0435:                try {
0436:                    BnNodeLocal nd = mProject.getBnNode(node);
0437:                    try {
0438:                        uHome = (BnUserLocalHome) hero.interfaces.BnUserUtil
0439:                                .getLocalHome();
0440:                    } catch (javax.naming.NamingException be) {
0441:                        throw new HeroException(be.getMessage());
0442:                    }
0443:                    try {
0444:                        user = uHome.findByName(nd.getExecutor());
0445:                    } catch (FinderException f) {
0446:                        throw new HeroException("FinderException");
0447:                    }
0448:                    BnUserLightValue ul = user.getBnUserLightValue();
0449:
0450:                    StringWriter sw = new StringWriter();
0451:                    Marshaller.marshal(ul, sw);
0452:                    return (sw.toString());
0453:                } catch (MarshalException ex1) {
0454:                    throw new HeroException(ex1.getMessage());
0455:                } catch (ValidationException ex2) {
0456:                    throw new HeroException(ex2.getMessage());
0457:                }
0458:            }
0459:
0460:            /**
0461:             * Get the state of the node
0462:             *
0463:             * @param name of the node
0464:             * @return The state of the node
0465:             * @ejb:interface-method view-type="both"
0466:             * @ejb:transaction type="Supports"
0467:             *
0468:             **/
0469:            public int getNodeState(String name) throws HeroException {
0470:
0471:                trace.debug(" Parameter: name=" + name + "process name = "
0472:                        + this .getName() + " started by "
0473:                        + mContext.getCallerPrincipal().getName());
0474:                BnNodeLocal nd = mProject.getBnNode(name);
0475:                return (nd.getState());
0476:            }
0477:
0478:            /**
0479:             * Get the type of the node
0480:             *
0481:             * @param name of the node
0482:             * @return The type of the node
0483:             * @ejb:interface-method view-type="both"
0484:             * @ejb:transaction type="Supports"
0485:             *
0486:             **/
0487:            public int getNodeType(String name) throws HeroException {
0488:
0489:                trace.debug(" Parameter: name=" + name + "process name = "
0490:                        + this .getName() + " started by "
0491:                        + mContext.getCallerPrincipal().getName());
0492:                BnNodeLocal nd = mProject.getBnNode(name);
0493:                return (nd.getType());
0494:            }
0495:
0496:            /**
0497:             * Get the node Value
0498:             *
0499:             * @param name the name of the BnNode
0500:             *
0501:             * @ejb:interface-method view-type="both"
0502:             * @ejb:transaction type="Supports"
0503:             *
0504:             **/
0505:            public String getNodeValue(String name) throws HeroException {
0506:
0507:                trace.debug(" Parameter: name=" + name + "process name = "
0508:                        + this .getName() + " started by "
0509:                        + mContext.getCallerPrincipal().getName());
0510:                BnNodeLocalHome nHome;
0511:                BnNodeLocal mNode;
0512:                BnNodeValue nv;
0513:                try {
0514:                    nHome = hero.interfaces.BnNodeUtil.getLocalHome();
0515:                } catch (javax.naming.NamingException be) {
0516:                    throw new HeroException(be.getMessage());
0517:                }
0518:                try {
0519:                    mNode = nHome.findByName(name, mProject.getId());
0520:                    nv = mNode.getBnNodeValue();
0521:                    StringWriter sw = new StringWriter();
0522:                    Marshaller.marshal(nv, sw);
0523:                    return (sw.toString());
0524:                } catch (MarshalException ex1) {
0525:                    throw new HeroException(ex1.getMessage());
0526:                } catch (ValidationException ex2) {
0527:                    throw new HeroException(ex2.getMessage());
0528:                } catch (FinderException fe) {
0529:                    throw new HeroException("This Node does not exist");
0530:                }
0531:            }
0532:
0533:            /**
0534:             * Get all nodes of this project
0535:             *
0536:             * @ejb:interface-method view-type="both"
0537:             * @ejb:transaction type="Supports"
0538:             *
0539:             **/
0540:
0541:            public String getNodes() throws HeroException {
0542:
0543:                trace.debug("process name = " + this .getName() + " started by "
0544:                        + mContext.getCallerPrincipal().getName());
0545:                ProjectNodes nb = new ProjectNodes();
0546:                Collection nodes = new ArrayList();
0547:                ArrayList ns = new ArrayList();
0548:                StringWriter sw = new StringWriter();
0549:
0550:                nodes = mProject.getBnNodes();
0551:                Iterator i = nodes.iterator();
0552:                while (i.hasNext()) {
0553:                    BnNodeLocal n = (BnNodeLocal) i.next();
0554:                    StrutsNodeValue snv = new StrutsNodeValue();
0555:                    snv.setProjectName(mProject.getName());
0556:                    snv.setName(n.getName());
0557:                    snv.setCreator(n.getCreator());
0558:                    snv.setRole(n.getBnRole().getName());
0559:                    snv.setState(Constants.Nd.nodeStateName[n.getState()]);
0560:                    snv.setType(Constants.Nd.nodeTypeName[n.getType()]);
0561:                    if (n.getDescription() != null)
0562:                        snv.setDescription(n.getDescription());
0563:                    if (n.getExecutor() != null)
0564:                        snv.setExecutor(n.getExecutor());
0565:                    snv.setAnticipable(n.getAnticipable());
0566:                    if (n.getDeadlines().size() != 0) {
0567:                        Collection co = n.getDeadlines();
0568:                        Iterator it = co.iterator();
0569:                        Date date = null;
0570:                        while (it.hasNext()) {
0571:                            date = (Date) it.next();
0572:                        }
0573:                        snv.setDeadline(date.toString());
0574:                    }
0575:                    ns.add(snv);
0576:                }
0577:                nb.setNodes(ns.toArray());
0578:
0579:                try {
0580:                    Marshaller.marshal(nb, sw);
0581:                } catch (MarshalException e) {
0582:                    e.printStackTrace();
0583:                } catch (ValidationException e) {
0584:                    e.printStackTrace();
0585:                }
0586:                return (sw.toString());
0587:            }
0588:
0589:            /**
0590:             * Get all node names of the project
0591:             *
0592:             * @ejb:interface-method view-type="both"
0593:             * @ejb:transaction type="Supports"
0594:             *
0595:             **/
0596:            public Collection getNodesNames() throws HeroException {
0597:
0598:                trace.debug("process name = " + this .getName() + " started by "
0599:                        + mContext.getCallerPrincipal().getName());
0600:
0601:                //	Vector names = new Vector();
0602:                ArrayList names = new ArrayList();
0603:                Collection nodes = mProject.getBnNodes();
0604:                Iterator i = nodes.iterator();
0605:                while (i.hasNext()) {
0606:                    BnNodeLocal n = (BnNodeLocal) i.next();
0607:                    names.add(n.getName());
0608:                }
0609:                return ((Collection) names);
0610:            }
0611:
0612:            /**
0613:             * Get all users of this project
0614:             *
0615:             * @ejb:interface-method view-type="both"
0616:             * @ejb:transaction type="Supports"
0617:             *
0618:             **/
0619:
0620:            public String getUsers() throws HeroException {
0621:
0622:                trace.debug("process name = " + this .getName() + " started by "
0623:                        + mContext.getCallerPrincipal().getName());
0624:                ProjectUsers ub = new ProjectUsers();
0625:                Collection us = new ArrayList();
0626:
0627:                try {
0628:                    Collection users = mProject.getBnUsers();
0629:                    Iterator i = users.iterator();
0630:                    while (i.hasNext()) {
0631:                        BnUserLocal u = (BnUserLocal) i.next();
0632:                        BnUserLightValue ul = u.getBnUserLightValue();
0633:                        us.add(ul);
0634:                    }
0635:                    ub.setUser(us);
0636:                    StringWriter sw = new StringWriter();
0637:                    Marshaller.marshal(ub, sw);
0638:                    return (sw.toString());
0639:                } catch (MarshalException ex1) {
0640:                    throw new HeroException(ex1.getMessage());
0641:                } catch (ValidationException ex2) {
0642:                    throw new HeroException(ex2.getMessage());
0643:                }
0644:            }
0645:
0646:            /**
0647:             * Get user roles in project names
0648:             * @return Collection 
0649:             *
0650:             * @param userName The name of the user
0651:             *
0652:             * @ejb:interface-method view-type="both"
0653:             * @ejb:transaction type="Supports"
0654:             *
0655:             **/
0656:            public Collection getUserRolesInProjectNames(String userName)
0657:                    throws HeroException {
0658:
0659:                trace.debug(" Parameter: userName=" + userName
0660:                        + "process name = " + this .getName() + " started by "
0661:                        + mContext.getCallerPrincipal().getName());
0662:                BnUserLocalHome uHome;
0663:                BnUserLocal user;
0664:                ArrayList result = new ArrayList();
0665:                try {
0666:                    uHome = (BnUserLocalHome) hero.interfaces.BnUserUtil
0667:                            .getLocalHome();
0668:                } catch (javax.naming.NamingException be) {
0669:                    throw new HeroException(be.getMessage());
0670:                }
0671:                try {
0672:                    user = uHome.findByName(userName);
0673:                } catch (FinderException f) {
0674:                    throw new HeroException("FinderException");
0675:                }
0676:
0677:                Collection userRoles = user.getBnRoles();
0678:                Collection projectRoles = mProject.getBnRoles();
0679:                for (Iterator i = userRoles.iterator(); i.hasNext();) {
0680:                    BnRoleLocal ur = (BnRoleLocal) i.next();
0681:                    for (Iterator j = projectRoles.iterator(); j.hasNext();) {
0682:                        BnRoleLocal up = (BnRoleLocal) j.next();
0683:                        if (ur.getId().equals(up.getId()))
0684:                            result.add(ur.getBnRoleValue().getName());
0685:                    }
0686:                }
0687:                return result;
0688:            }
0689:
0690:            /**
0691:             * Get all roles of this project
0692:             *
0693:             * @ejb:interface-method view-type="both"
0694:             * @ejb:transaction type="Supports"
0695:             *
0696:             **/
0697:
0698:            public String getRoles() throws HeroException {
0699:
0700:                trace.debug("process name = " + this .getName() + " started by "
0701:                        + mContext.getCallerPrincipal().getName());
0702:                ProjectRoles rb = new ProjectRoles();
0703:                Collection rs = new ArrayList();
0704:
0705:                try {
0706:                    Collection roles = mProject.getBnRoles();
0707:                    Iterator i = roles.iterator();
0708:                    while (i.hasNext()) {
0709:                        BnRoleLocal r = (BnRoleLocal) i.next();
0710:                        BnRoleValue rl = r.getBnRoleValue();
0711:                        rs.add(rl);
0712:                    }
0713:                    rb.setRole(rs);
0714:                    StringWriter sw = new StringWriter();
0715:                    Marshaller.marshal(rb, sw);
0716:                    return (sw.toString());
0717:                } catch (MarshalException ex1) {
0718:                    throw new HeroException(ex1.getMessage());
0719:                } catch (ValidationException ex2) {
0720:                    throw new HeroException(ex2.getMessage());
0721:                }
0722:            }
0723:
0724:            /**
0725:             * Get all roles names of the project
0726:             * @return Collection 
0727:             *
0728:             * @ejb:interface-method view-type="both"
0729:             * @ejb:transaction type="Supports"
0730:             *
0731:             **/
0732:            public Collection getRolesNames() throws HeroException {
0733:
0734:                trace.debug("process name = " + this .getName() + " started by "
0735:                        + mContext.getCallerPrincipal().getName());
0736:                Collection roles = mProject.getBnRoles();
0737:                ArrayList result = new ArrayList();
0738:                for (Iterator i = roles.iterator(); i.hasNext();) {
0739:                    result.add(((BnRoleLocal) i.next()).getName());
0740:                }
0741:                return result;
0742:            }
0743:
0744:            /**
0745:             * Get user roles for this project
0746:             *
0747:             * @ejb:interface-method view-type="both"
0748:             * @ejb:transaction type="Supports"
0749:             *
0750:             **/
0751:
0752:            public String getUserRoles(String userName) throws HeroException {
0753:
0754:                trace.debug(" Parameter: userName=" + userName
0755:                        + "process name = " + this .getName() + " started by "
0756:                        + mContext.getCallerPrincipal().getName());
0757:                BnUserLocalHome uHome;
0758:                BnUserLocal user;
0759:                Collection result = new ArrayList();
0760:                ProjectRoles rb = new ProjectRoles();
0761:                try {
0762:                    uHome = (BnUserLocalHome) BnUserUtil.getLocalHome();
0763:                } catch (javax.naming.NamingException be) {
0764:                    throw new HeroException(be.getMessage());
0765:                }
0766:                try {
0767:                    user = uHome.findByName(userName);
0768:                } catch (FinderException f) {
0769:                    throw new HeroException("FinderException");
0770:                }
0771:                Collection userRoles = user.getBnRoles();
0772:                Collection projectRoles = mProject.getBnRoles();
0773:                for (Iterator i = userRoles.iterator(); i.hasNext();) {
0774:                    BnRoleLocal ur = (BnRoleLocal) i.next();
0775:                    for (Iterator j = projectRoles.iterator(); j.hasNext();) {
0776:                        BnRoleLocal up = (BnRoleLocal) j.next();
0777:                        if (ur.getId() == up.getId())
0778:                            result.add(ur.getBnRoleValue());
0779:                    }
0780:                }
0781:                try {
0782:                    rb.setRole(result);
0783:                    StringWriter sw = new StringWriter();
0784:                    Marshaller.marshal(rb, sw);
0785:                    return (sw.toString());
0786:                } catch (MarshalException ex1) {
0787:                    throw new HeroException(ex1.getMessage());
0788:                } catch (ValidationException ex2) {
0789:                    throw new HeroException(ex2.getMessage());
0790:                }
0791:            }
0792:
0793:            /**
0794:             * Get user roles in project
0795:             * @return Collection 
0796:             *
0797:             * @param userName The name of the user
0798:             *
0799:             * @ejb:interface-method view-type="both"
0800:             * @ejb:transaction type="Supports"
0801:             *
0802:             **/
0803:            public String getUserRolesInProject(String userName)
0804:                    throws HeroException {
0805:
0806:                trace.debug(" Parameter: userName=" + userName
0807:                        + "process name = " + this .getName() + " started by "
0808:                        + mContext.getCallerPrincipal().getName());
0809:                BnUserLocalHome uHome;
0810:                BnUserLocal user;
0811:                ArrayList result = new ArrayList();
0812:                ProjectRoles rb = new ProjectRoles();
0813:                try {
0814:                    uHome = (BnUserLocalHome) hero.interfaces.BnUserUtil
0815:                            .getLocalHome();
0816:                } catch (javax.naming.NamingException be) {
0817:                    throw new HeroException(be.getMessage());
0818:                }
0819:                try {
0820:                    user = uHome.findByName(userName);
0821:                } catch (FinderException f) {
0822:                    throw new HeroException("FinderException");
0823:                }
0824:                Collection userRoles = user.getBnRoles();
0825:                Collection projectRoles = mProject.getBnRoles();
0826:                for (Iterator i = userRoles.iterator(); i.hasNext();) {
0827:                    BnRoleLocal ur = (BnRoleLocal) i.next();
0828:                    for (Iterator j = projectRoles.iterator(); j.hasNext();) {
0829:                        BnRoleLocal up = (BnRoleLocal) j.next();
0830:                        if (ur.getId() == up.getId())
0831:                            result.add(ur.getBnRoleValue());
0832:                    }
0833:                }
0834:                try {
0835:                    rb.setRole(result);
0836:                    StringWriter sw = new StringWriter();
0837:                    Marshaller.marshal(rb, sw);
0838:                    return (sw.toString());
0839:                } catch (MarshalException ex1) {
0840:                    throw new HeroException(ex1.getMessage());
0841:                } catch (ValidationException ex2) {
0842:                    throw new HeroException(ex2.getMessage());
0843:                }
0844:            }
0845:
0846:            /**
0847:             * Get the properties of this project
0848:             *
0849:             * @ejb:interface-method view-type="both"
0850:             * @ejb:transaction type="Supports"
0851:             *
0852:             **/
0853:
0854:            public String getProperties() throws HeroException {
0855:
0856:                trace.debug("process name = " + this .getName() + " started by "
0857:                        + mContext.getCallerPrincipal().getName());
0858:                ProjectProperties pb = new ProjectProperties();
0859:                Collection ps = new ArrayList();
0860:
0861:                try {
0862:                    Collection properties = mProject.getBnProperties();
0863:                    Iterator i = properties.iterator();
0864:                    while (i.hasNext()) {
0865:                        BnProjectPropertyLocal pp = (BnProjectPropertyLocal) i
0866:                                .next();
0867:                        BnProjectPropertyValue ppv = pp
0868:                                .getBnProjectPropertyValue();
0869:                        ps.add(ppv);
0870:                    }
0871:                    pb.setProperty(ps);
0872:                    StringWriter sw = new StringWriter();
0873:                    Marshaller.marshal(pb, sw);
0874:                    return (sw.toString());
0875:                } catch (MarshalException ex1) {
0876:                    throw new HeroException(ex1.getMessage());
0877:                } catch (ValidationException ex2) {
0878:                    throw new HeroException(ex2.getMessage());
0879:                }
0880:            }
0881:
0882:            /**
0883:             * Get the hooks of this project
0884:             *
0885:             * @ejb:interface-method view-type="both"
0886:             * @ejb:transaction type="Supports"
0887:             *
0888:             **/
0889:
0890:            public String getHooks() throws HeroException {
0891:
0892:                trace.debug("process name = " + this .getName() + " started by "
0893:                        + mContext.getCallerPrincipal().getName());
0894:                ProjectHooks hb = new ProjectHooks();
0895:                Collection hs = new ArrayList();
0896:
0897:                try {
0898:                    Collection hooks = mProject.getBnHooks();
0899:                    Iterator i = hooks.iterator();
0900:                    while (i.hasNext()) {
0901:                        BnProjectHookLocal ph = (BnProjectHookLocal) i.next();
0902:                        BnProjectHookValue phv = ph.getBnProjectHookValue();
0903:                        hs.add(phv);
0904:                    }
0905:                    hb.setHook(hs);
0906:                    StringWriter sw = new StringWriter();
0907:                    Marshaller.marshal(hb, sw);
0908:                    return (sw.toString());
0909:                } catch (MarshalException ex1) {
0910:                    throw new HeroException(ex1.getMessage());
0911:                } catch (ValidationException ex2) {
0912:                    throw new HeroException(ex2.getMessage());
0913:                }
0914:            }
0915:
0916:            /**
0917:             * Get Interactive hooks of the project
0918:             *
0919:             * @return A BnProjectHookValue collection of all project inter hooks
0920:             * @ejb:interface-method view-type="both"
0921:             * @ejb:transaction type="Supports"
0922:             *
0923:             **/
0924:            public String getInterHooks() throws HeroException {
0925:
0926:                trace.debug("process name = " + this .getName() + " started by "
0927:                        + mContext.getCallerPrincipal().getName());
0928:                try {
0929:                    Collection hk = new ArrayList();
0930:                    ProjectHooks hb = new ProjectHooks();
0931:                    BnProjectInterHookLocal pl;
0932:                    Collection pls = mProject.getBnInterHooks();
0933:
0934:                    for (Iterator i = pls.iterator(); i.hasNext();) {
0935:                        pl = (BnProjectInterHookLocal) i.next();
0936:                        hk.add(pl.getBnProjectInterHookValue());
0937:                    }
0938:                    hb.setHook(hk);
0939:                    StringWriter sw = new StringWriter();
0940:                    Marshaller.marshal(hb, sw);
0941:                    return (sw.toString());
0942:                } catch (MarshalException ex1) {
0943:                    throw new HeroException(ex1.getMessage());
0944:                } catch (ValidationException ex2) {
0945:                    throw new HeroException(ex2.getMessage());
0946:                }
0947:            }
0948:
0949:            /**
0950:             * Get Interactive Node hooks of the project
0951:             *
0952:             * @param nodeName the name of the node
0953:             * @return A NodeHookValue collection of all node hooks (XML)
0954:             * @ejb:interface-method view-type="both"
0955:             * @ejb:transaction type="Supports"
0956:             *
0957:             **/
0958:            public String getNodeInterHooks(String nodeName)
0959:                    throws HeroException {
0960:
0961:                trace.debug(" Parameter: nodeName=" + nodeName
0962:                        + "process name = " + this .getName() + " started by "
0963:                        + mContext.getCallerPrincipal().getName());
0964:                try {
0965:                    Collection hk = new ArrayList();
0966:                    BnNodeInterHookLocal pl;
0967:                    ProjectHooks hb = new ProjectHooks();
0968:
0969:                    BnNodeLocal nd = mProject.getBnNode(nodeName);
0970:
0971:                    Collection pls = nd.getBnInterHooks();
0972:
0973:                    for (Iterator i = pls.iterator(); i.hasNext();) {
0974:                        pl = (BnNodeInterHookLocal) i.next();
0975:                        hk.add(pl.getBnNodeInterHookValue());
0976:                    }
0977:                    hb.setHook(hk);
0978:                    StringWriter sw = new StringWriter();
0979:                    Marshaller.marshal(hb, sw);
0980:                    return (sw.toString());
0981:                } catch (MarshalException ex1) {
0982:                    throw new HeroException(ex1.getMessage());
0983:                } catch (ValidationException ex2) {
0984:                    throw new HeroException(ex2.getMessage());
0985:                }
0986:            }
0987:
0988:            /**
0989:             * Get the node hook value. Only for interactives hooks
0990:             *
0991:             * @param name of the node
0992:             * @param hook of the node
0993:             * @ejb:interface-method view-type="both"
0994:             * @ejb:transaction type="Supports"
0995:             *
0996:             **/
0997:            public String getNodeInterHookValue(String node, String hook)
0998:                    throws HeroException {
0999:
1000:                trace.debug(" Parameter: node=" + node + " hook=  " + hook
1001:                        + "process name = " + this .getName() + " started by "
1002:                        + mContext.getCallerPrincipal().getName());
1003:                String value = null;
1004:                BnNodeLocal nd = mProject.getBnNode(node);
1005:                Collection hooks = nd.getBnInterHooks();
1006:                for (Iterator ih = hooks.iterator(); ih.hasNext();) {
1007:                    BnNodeInterHookLocal hk = (BnNodeInterHookLocal) ih.next();
1008:                    if (hk.getName().equals(hook)) {
1009:                        value = hk.getScript();
1010:                    }
1011:                }
1012:                return value;
1013:            }
1014:
1015:            /**
1016:             * Get Node inter hook of the project
1017:             *
1018:             * @param nodeName the name of the node
1019:             * @param interHook name
1020:             * @return A BnNodeInterHookValue 
1021:             * @ejb:interface-method view-type="both"
1022:             * @ejb:transaction type="Supports"
1023:             *
1024:             **/
1025:            public String getNodeInterHook(String nodeName, String interHook)
1026:                    throws HeroException {
1027:
1028:                trace.debug(" Parameter: nodeName" + nodeName + " interHook=  "
1029:                        + interHook + "process name = " + this .getName()
1030:                        + " started by "
1031:                        + mContext.getCallerPrincipal().getName());
1032:                try {
1033:                    BnNodeInterHookLocal hl;
1034:                    BnNodeLocal nd = mProject.getBnNode(nodeName);
1035:                    Collection hls = nd.getBnInterHooks();
1036:
1037:                    for (Iterator i = hls.iterator(); i.hasNext();) {
1038:                        hl = (BnNodeInterHookLocal) i.next();
1039:                        if (hl.getName().equals(interHook)) {
1040:                            StringWriter sw = new StringWriter();
1041:                            Marshaller
1042:                                    .marshal(hl.getBnNodeInterHookValue(), sw);
1043:                            return (sw.toString());
1044:                        }
1045:                    }
1046:                } catch (MarshalException ex1) {
1047:                    throw new HeroException(ex1.getMessage());
1048:                } catch (ValidationException ex2) {
1049:                    throw new HeroException(ex2.getMessage());
1050:                }
1051:                return null;
1052:            }
1053:
1054:            /**
1055:             * Return all registered users
1056:             * @return A string collection of all user names
1057:             *
1058:             * @ejb:interface-method view-type="both"
1059:             * @ejb:transaction type="Supports"
1060:             *
1061:             **/
1062:            public Collection getAllUsers() throws HeroException {
1063:
1064:                trace.debug("process name = " + this .getName() + " started by "
1065:                        + mContext.getCallerPrincipal().getName());
1066:                BnUserLocalHome uHome;
1067:                Collection users;
1068:                try {
1069:                    uHome = (BnUserLocalHome) hero.interfaces.BnUserUtil
1070:                            .getLocalHome();
1071:                } catch (javax.naming.NamingException be) {
1072:                    throw new HeroException(be.getMessage());
1073:                }
1074:                try {
1075:                    users = uHome.findAll();
1076:                } catch (FinderException f) {
1077:                    throw new HeroException(
1078:                            "FinderException in findByAll users");
1079:                }
1080:                ArrayList result = new ArrayList();
1081:                for (Iterator i = users.iterator(); i.hasNext();) {
1082:                    result.add(((BnUserLocal) i.next()).getName());
1083:                }
1084:                return result;
1085:            }
1086:
1087:            /**
1088:             * Return all registered users
1089:             * @return A string collection of all user names
1090:             *
1091:             * @ejb:interface-method view-type="both"
1092:             * @ejb:transaction type="Supports"
1093:             *
1094:             **/
1095:            public Collection getAllUsers(int offset, int numrows)
1096:                    throws HeroException {
1097:
1098:                trace.debug("process name = " + this .getName() + " started by "
1099:                        + mContext.getCallerPrincipal().getName());
1100:                BnUserLocalHome uHome;
1101:                Collection users;
1102:                try {
1103:                    uHome = (BnUserLocalHome) hero.interfaces.BnUserUtil
1104:                            .getLocalHome();
1105:                } catch (javax.naming.NamingException be) {
1106:                    throw new HeroException(be.getMessage());
1107:                }
1108:                try {
1109:                    users = uHome.findAll();
1110:                } catch (FinderException f) {
1111:                    throw new HeroException(
1112:                            "FinderException in findByAll users");
1113:                }
1114:                int cnt = 0;
1115:                int add = 0;
1116:                ArrayList result = new ArrayList();
1117:                for (Iterator i = users.iterator(); i.hasNext();) {
1118:                    BnUserLocal user = (BnUserLocal) i.next();
1119:                    if (cnt >= offset) {
1120:                        result.add(user.getName());
1121:                        add++;
1122:                        if (add == numrows)
1123:                            break;
1124:                    }
1125:                    cnt++;
1126:                }
1127:                return result;
1128:            }
1129:
1130:            /**
1131:             * Get number of total entities
1132:             * 
1133:             * @ejb:interface-method view-type="both"
1134:             * @ejb:transaction type="Supports"
1135:             *
1136:             **/
1137:            public int getListCnt(String type) throws HeroException {
1138:                trace.debug("type = " + type + "started by "
1139:                        + mContext.getCallerPrincipal().getName());
1140:                BnUserLocalHome uHome;
1141:                Collection list = null;
1142:                int cnt = 0;
1143:
1144:                if (type.equals(Constants.Pj.GETALLUSERS)) {
1145:                    try {
1146:                        uHome = (BnUserLocalHome) hero.interfaces.BnUserUtil
1147:                                .getLocalHome();
1148:                    } catch (javax.naming.NamingException be) {
1149:                        throw new HeroException(be.getMessage());
1150:                    }
1151:                    try {
1152:                        list = uHome.findAll();
1153:                    } catch (FinderException f) {
1154:                        throw new HeroException(
1155:                                "FinderException in findByAll users");
1156:                    }
1157:                }
1158:                for (Iterator i = list.iterator(); i.hasNext();) {
1159:                    i.next();
1160:                    cnt++;
1161:                }
1162:                return cnt;
1163:            }
1164:
1165:            /**
1166:             * Get the node properties of this project
1167:             *
1168:             * @ejb:interface-method view-type="both"
1169:             * @ejb:transaction type="Supports"
1170:             *
1171:             **/
1172:
1173:            public String getNodeProperties(String nodeName)
1174:                    throws HeroException {
1175:
1176:                trace.debug(" Parameter: nodeName=" + nodeName
1177:                        + "process name = " + this .getName() + " started by "
1178:                        + mContext.getCallerPrincipal().getName());
1179:                NodeProperties nb = new NodeProperties();
1180:                Collection ns = new ArrayList();
1181:
1182:                try {
1183:                    BnNodeLocal nl = mProject.getBnNode(nodeName);
1184:                    Collection properties = nl.getBnProperties();
1185:                    Iterator i = properties.iterator();
1186:                    while (i.hasNext()) {
1187:                        BnNodePropertyLocal np = (BnNodePropertyLocal) i.next();
1188:                        BnNodePropertyValue npv = np.getBnNodePropertyValue();
1189:                        ns.add(npv);
1190:                    }
1191:                    nb.setProjectName(mProject.getName());
1192:                    nb.setProperty(ns);
1193:                    StringWriter sw = new StringWriter();
1194:                    Marshaller.marshal(nb, sw);
1195:                    return (sw.toString());
1196:                } catch (MarshalException ex1) {
1197:                    throw new HeroException(ex1.getMessage());
1198:                } catch (ValidationException ex2) {
1199:                    throw new HeroException(ex2.getMessage());
1200:                }
1201:            }
1202:
1203:            /**
1204:             * Get Node property of the project
1205:             *
1206:             * @param nodeName the name of the node
1207:             * @param key Property key
1208:             * @return A BnNodePropertyValue 
1209:             * @ejb:interface-method view-type="both"
1210:             * @ejb:transaction type="Supports"
1211:             *
1212:             **/
1213:            public String getNodeProperty(String nodeName, String key)
1214:                    throws HeroException {
1215:
1216:                trace.debug(" Parameter: nodeName" + nodeName + " key=  " + key
1217:                        + "process name = " + this .getName() + " started by "
1218:                        + mContext.getCallerPrincipal().getName());
1219:                try {
1220:                    BnNodePropertyLocal pl;
1221:                    BnNodeLocal nd = mProject.getBnNode(nodeName);
1222:                    Collection pls = nd.getBnProperties();
1223:
1224:                    for (Iterator i = pls.iterator(); i.hasNext();) {
1225:                        pl = (BnNodePropertyLocal) i.next();
1226:                        if (pl.getTheKey().equals(key)) {
1227:                            StringWriter sw = new StringWriter();
1228:                            Marshaller.marshal(pl.getBnNodePropertyValue(), sw);
1229:                            return (sw.toString());
1230:                        }
1231:                    }
1232:                } catch (MarshalException ex1) {
1233:                    throw new HeroException(ex1.getMessage());
1234:                } catch (ValidationException ex2) {
1235:                    throw new HeroException(ex2.getMessage());
1236:                }
1237:                return (null);
1238:            }
1239:
1240:            /**
1241:             * Get the node hooks of this project
1242:             *
1243:             * @ejb:interface-method view-type="both"
1244:             * @ejb:transaction type="Supports"
1245:             *
1246:             **/
1247:
1248:            public String getNodeHooks(String nodeName) throws HeroException {
1249:
1250:                trace.debug(" Parameter: nodeName=" + nodeName
1251:                        + "process name = " + this .getName() + " started by "
1252:                        + mContext.getCallerPrincipal().getName());
1253:                NodeHooks nb = new NodeHooks();
1254:                Collection hs = new ArrayList();
1255:
1256:                try {
1257:                    BnNodeLocal nl = mProject.getBnNode(nodeName);
1258:                    Collection hooks = nl.getBnHooks();
1259:                    Iterator i = hooks.iterator();
1260:                    while (i.hasNext()) {
1261:                        BnNodeHookLocal nh = (BnNodeHookLocal) i.next();
1262:                        BnNodeHookValue nhv = nh.getBnNodeHookValue();
1263:                        hs.add(nhv);
1264:                    }
1265:                    nb.setProjectName(mProject.getName());
1266:                    nb.setHook(hs);
1267:                    StringWriter sw = new StringWriter();
1268:                    Marshaller.marshal(nb, sw);
1269:                    return (sw.toString());
1270:                } catch (MarshalException ex1) {
1271:                    throw new HeroException(ex1.getMessage());
1272:                } catch (ValidationException ex2) {
1273:                    throw new HeroException(ex2.getMessage());
1274:                }
1275:            }
1276:
1277:            /**
1278:             * Get creator of the project
1279:             * @return String 
1280:             *
1281:             * @ejb:interface-method view-type="both"
1282:             * @ejb:transaction type="Supports"
1283:             *
1284:             **/
1285:            public String getCreator() throws HeroException {
1286:
1287:                trace.debug("process name = " + this .getName() + " started by "
1288:                        + mContext.getCallerPrincipal().getName());
1289:                return mProject.getCreator();
1290:            }
1291:
1292:            /**
1293:             * get all in edges of the node
1294:             * @return String
1295:             *
1296:             * @param name the name ot the node
1297:             *
1298:             * @ejb:interface-method view-type="both"
1299:             * @ejb:transaction type="Supports"
1300:             *
1301:             **/
1302:            public String getNodeInEdges(String name) throws HeroException {
1303:
1304:                trace.debug(" Parameter: name=" + name + "process name = "
1305:                        + this .getName() + " started by "
1306:                        + mContext.getCallerPrincipal().getName());
1307:                NodeInEdges eb = new NodeInEdges();
1308:                Collection in = new ArrayList();
1309:
1310:                try {
1311:                    BnNodeLocal nd = mProject.getBnNode(name);
1312:
1313:                    Collection edgesIn = nd.getInBnEdges();
1314:                    Iterator i = edgesIn.iterator();
1315:                    while (i.hasNext())
1316:                        in.add(((BnEdgeLocal) i.next()).getBnEdgeValue());
1317:
1318:                    eb.setProjectName(mProject.getName());
1319:                    eb.setInEdge(in);
1320:                    StringWriter sw = new StringWriter();
1321:                    Marshaller.marshal(eb, sw);
1322:                    return (sw.toString());
1323:                } catch (MarshalException ex1) {
1324:                    throw new HeroException(ex1.getMessage());
1325:                } catch (ValidationException ex2) {
1326:                    throw new HeroException(ex2.getMessage());
1327:                }
1328:            }
1329:
1330:            /**
1331:             * Get the edge Condition
1332:             *
1333:             * @param edge name
1334:             * @ejb:interface-method view-type="both"
1335:             * @ejb:transaction type="Supports"
1336:             *
1337:             **/
1338:            public String getEdgeCondition(String edge) throws HeroException {
1339:
1340:                trace.debug(" Parameter: edge=" + edge + "process name = "
1341:                        + this .getName() + " started by "
1342:                        + mContext.getCallerPrincipal().getName());
1343:                BnEdgeLocal e = mProject.getBnEdge(edge);
1344:                return (e.getCondition());
1345:            }
1346:
1347:            /**
1348:             * Get edge in node
1349:             * @return String 
1350:             *
1351:             * @ejb:interface-method view-type="both"
1352:             * @ejb:transaction type="Supports"
1353:             *
1354:             **/
1355:            public String getEdgeInNode(String edgeName) throws HeroException {
1356:
1357:                trace.debug(" Parameter: edgeName=" + edgeName
1358:                        + "process name = " + this .getName() + " started by "
1359:                        + mContext.getCallerPrincipal().getName());
1360:                BnEdgeLocal e = mProject.getBnEdge(edgeName);
1361:                return (((BnNodeLocal) e.getInBnNode()).getName());
1362:            }
1363:
1364:            /**
1365:             * Get edge out node
1366:             * @return String 
1367:             *
1368:             * @ejb:interface-method view-type="both"
1369:             * @ejb:transaction type="Supports"
1370:             *
1371:             **/
1372:            public String getEdgeOutNode(String edgeName) throws HeroException {
1373:
1374:                trace.debug(" Parameter: edgeName=" + edgeName
1375:                        + "process name = " + this .getName() + " started by "
1376:                        + mContext.getCallerPrincipal().getName());
1377:                BnEdgeLocal e = mProject.getBnEdge(edgeName);
1378:                return (((BnNodeLocal) e.getOutBnNode()).getName());
1379:            }
1380:
1381:            /**
1382:             * Get all edges of the project
1383:             * @return Collection 
1384:             *
1385:             * @ejb:interface-method view-type="both"
1386:             * @ejb:transaction type="Supports"
1387:             *
1388:             **/
1389:            public Collection getEdgesNames() throws HeroException {
1390:
1391:                trace.debug("process name = " + this .getName() + " started by "
1392:                        + mContext.getCallerPrincipal().getName());
1393:                //	Vector names = new Vector();
1394:                ArrayList names = new ArrayList();
1395:                Collection edges = mProject.getBnEdges();
1396:                Iterator i = edges.iterator();
1397:                while (i.hasNext()) {
1398:                    BnEdgeLocal n = (BnEdgeLocal) i.next();
1399:                    names.add(n.getName());
1400:                }
1401:                return ((Collection) names);
1402:            }
1403:
1404:            /**
1405:             * get all out edges of the node
1406:             * @return Collection 
1407:             *
1408:             * @param name the name ot the node
1409:             *
1410:             * @ejb:interface-method view-type="both"
1411:             * @ejb:transaction type="Supports"
1412:             *
1413:             **/
1414:            public String getNodeOutEdges(String name) throws HeroException {
1415:
1416:                trace.debug(" Parameter: name=" + name + "process name = "
1417:                        + this .getName() + " started by "
1418:                        + mContext.getCallerPrincipal().getName());
1419:                NodeOutEdges eb = new NodeOutEdges();
1420:                Collection out = new ArrayList();
1421:
1422:                try {
1423:                    BnNodeLocal nd = mProject.getBnNode(name);
1424:
1425:                    Collection edgesOut = nd.getOutBnEdges();
1426:                    Iterator i = edgesOut.iterator();
1427:                    while (i.hasNext())
1428:                        out.add(((BnEdgeLocal) i.next()).getBnEdgeValue());
1429:
1430:                    eb.setProjectName(mProject.getName());
1431:                    eb.setOutEdge(out);
1432:                    StringWriter sw = new StringWriter();
1433:                    Marshaller.marshal(eb, sw);
1434:                    return (sw.toString());
1435:                } catch (MarshalException ex1) {
1436:                    throw new HeroException(ex1.getMessage());
1437:                } catch (ValidationException ex2) {
1438:                    throw new HeroException(ex2.getMessage());
1439:                }
1440:            }
1441:
1442:            /**
1443:             * Get the Edge Value
1444:             *
1445:             * @param name the name of the Edge
1446:             *
1447:             * @ejb:interface-method view-type="both"
1448:             * @ejb:transaction type="Supports"
1449:             *
1450:             **/
1451:            public String getEdgeValue(String name) throws HeroException {
1452:
1453:                trace.debug(" Parameter: name=" + name + "process name = "
1454:                        + this .getName() + " started by "
1455:                        + mContext.getCallerPrincipal().getName());
1456:                BnEdgeLocalHome eHome;
1457:                BnEdgeLocal mEdge;
1458:                BnEdgeValue ev;
1459:                try {
1460:                    eHome = hero.interfaces.BnEdgeUtil.getLocalHome();
1461:                } catch (javax.naming.NamingException be) {
1462:                    throw new HeroException(be.getMessage());
1463:                }
1464:                try {
1465:                    mEdge = eHome.findByName(name, mProject.getId());
1466:                    ev = mEdge.getBnEdgeValue();
1467:                    StringWriter sw = new StringWriter();
1468:                    Marshaller.marshal(ev, sw);
1469:                    return (sw.toString());
1470:                } catch (MarshalException ex1) {
1471:                    throw new HeroException(ex1.getMessage());
1472:                } catch (ValidationException ex2) {
1473:                    throw new HeroException(ex2.getMessage());
1474:                } catch (FinderException fe) {
1475:                    throw new HeroException("BnEdge does not exist");
1476:                }
1477:            }
1478:
1479:            /**
1480:             * Get the node in traditional mode
1481:             *
1482:             * @param name of the node
1483:             * @ejb:interface-method view-type="both"
1484:             * @ejb:transaction type="Required"
1485:             *
1486:             **/
1487:            public boolean getNodeAnticipable(String name) throws HeroException {
1488:
1489:                trace.debug(" Parameter: name=" + name + "process name = "
1490:                        + this .getName() + " started by "
1491:                        + mContext.getCallerPrincipal().getName());
1492:                BnNodeLocal nd = mProject.getBnNode(name);
1493:                return (nd.getAnticipable());
1494:            }
1495:
1496:            /**
1497:             * Get the inter hook value script
1498:             *
1499:             * @param script of the inter hook
1500:             * @ejb:interface-method view-type="both"
1501:             * @ejb:transaction type="Supports"
1502:             *
1503:             **/
1504:            public String getInterHookValue(String hook) throws HeroException {
1505:                String value = null;
1506:
1507:                trace.debug(" Parameter: hook=" + hook + "process name = "
1508:                        + this .getName() + " started by "
1509:                        + mContext.getCallerPrincipal().getName());
1510:                Collection hooks = mProject.getBnInterHooks();
1511:                for (Iterator ih = hooks.iterator(); ih.hasNext();) {
1512:                    BnProjectInterHookLocal hk = (BnProjectInterHookLocal) ih
1513:                            .next();
1514:                    if (hk.getName().equals(hook)) {
1515:                        value = hk.getScript();
1516:                    }
1517:                }
1518:                return value;
1519:            }
1520:
1521:            /**
1522:             * Get the project name of this instance
1523:             *
1524:             * @param instanceName the name of the instance
1525:             * @ejb:interface-method view-type="both"
1526:             * @ejb:transaction type="Supports"
1527:             *
1528:             **/
1529:            public String getProjectNameOfInstance(String instanceName)
1530:                    throws HeroException {
1531:
1532:                trace.debug(" Parameter: instanceName=" + instanceName
1533:                        + "process name = " + this .getName() + " started by "
1534:                        + mContext.getCallerPrincipal().getName());
1535:                if (instanceName.matches(".*" + "_instance" + ".*")) {
1536:                    int i = instanceName.indexOf("_instance");
1537:                    return (instanceName.substring(0, i));
1538:                } else
1539:                    throw new HeroException(instanceName
1540:                            + " is not a project instance...");
1541:            }
1542:
1543:            /**
1544:             * Init the Project Session Bean. You have to call this method after "create" call. After that
1545:             * all methods of ProjectSession API are available.
1546:             *
1547:             * @param projectName project name 
1548:             * @ejb:interface-method view-type="both"
1549:             * @ejb:transaction type="Required"
1550:             * @throws HeroException
1551:             **/
1552:            public void initProject(String projectName) throws HeroException {
1553:
1554:                trace.debug(" Parameter: projectName=" + projectName
1555:                        + " started by "
1556:                        + mContext.getCallerPrincipal().getName());
1557:                Context lContext;
1558:                BnUserLocalHome uhome = null;
1559:                BnRoleLocalHome rhome = null;
1560:                try {
1561:                    pHome = hero.interfaces.BnProjectUtil.getLocalHome();
1562:                    this .mProject = pHome.findByName(projectName);
1563:                } catch (javax.naming.NamingException ne) {
1564:                    throw new HeroException(ne.getMessage());
1565:                } catch (javax.ejb.FinderException fe) {
1566:                    throw new HeroException(fe.getMessage());
1567:                }
1568:            }
1569:
1570:            /**
1571:             * Creates the Project Session Bean. This method is the first one to invoke in order to
1572:             * use ProjectSession API. If the user is not authorized this method throws an exception.
1573:             *
1574:             * @throws CreateException 
1575:             *
1576:             * @ejb:create-method view-type="both"
1577:             **/
1578:            public void ejbCreate() throws CreateException {
1579:            }
1580:
1581:            /**
1582:             * Internal Enterprise Java Beans method. 
1583:             **/
1584:            public void ejbPostCreate(String oldProject, String newProject)
1585:                    throws CreateException, RemoteException {
1586:            }
1587:
1588:            /**
1589:             * Internal Enterprise Java Beans method. 
1590:             **/
1591:            public void setSessionContext(final javax.ejb.SessionContext context) {
1592:                mContext = context;
1593:            }
1594:
1595:            /**
1596:             * Internal Enterprise Java Beans method. 
1597:             **/
1598:
1599:            public void ejbRemove() {
1600:            }
1601:
1602:            /**
1603:             * Internal Enterprise Java Beans method. 
1604:             **/
1605:
1606:            public void ejbActivate() {
1607:            }
1608:
1609:            /**
1610:             * Internal Enterprise Java Beans method. 
1611:             **/
1612:
1613:            public void ejbPassivate() {
1614:            }
1615:
1616:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.