Source Code Cross Referenced for J2EEServerEJB.java in  » Workflow-Engines » obe-1.0 » org » obe » server » j2ee » 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 » obe 1.0 » org.obe.server.j2ee 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


0001:        /*--
0002:
0003:         Copyright (C) 2002-2005 Adrian Price.
0004:         All rights reserved.
0005:
0006:         Redistribution and use in source and binary forms, with or without
0007:         modification, are permitted provided that the following conditions
0008:         are met:
0009:
0010:         1. Redistributions of source code must retain the above copyright
0011:            notice, this list of conditions, and the following disclaimer.
0012:
0013:         2. Redistributions in binary form must reproduce the above copyright
0014:            notice, this list of conditions, and the disclaimer that follows
0015:            these conditions in the documentation and/or other materials
0016:            provided with the distribution.
0017:
0018:         3. The names "OBE" and "Open Business Engine" must not be used to
0019:         	endorse or promote products derived from this software without prior
0020:         	written permission.  For written permission, please contact
0021:         	adrianprice@sourceforge.net.
0022:
0023:         4. Products derived from this software may not be called "OBE" or
0024:         	"Open Business Engine", nor may "OBE" or "Open Business Engine"
0025:         	appear in their name, without prior written permission from
0026:         	Adrian Price (adrianprice@users.sourceforge.net).
0027:
0028:         THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
0029:         WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
0030:         OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
0031:         DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT,
0032:         INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
0033:         (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
0034:         SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
0035:         HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
0036:         STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
0037:         IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
0038:         POSSIBILITY OF SUCH DAMAGE.
0039:
0040:         For more information on OBE, please see
0041:         <http://obe.sourceforge.net/>.
0042:
0043:         */
0044:
0045:        package org.obe.server.j2ee;
0046:
0047:        import org.apache.commons.logging.Log;
0048:        import org.apache.log4j.NDC;
0049:        import org.obe.client.api.WMClient;
0050:        import org.obe.client.api.tool.Parameter;
0051:        import org.obe.client.api.tool.ToolInvocation;
0052:        import org.obe.engine.WorkflowEngine;
0053:        import org.obe.server.j2ee.ejb.AbstractSessionEJB;
0054:        import org.obe.spi.event.ApplicationEvent;
0055:        import org.obe.spi.service.ServerConfig;
0056:        import org.obe.xpdl.model.pkg.XPDLPackage;
0057:        import org.wfmc.audit.WMAAuditEntry;
0058:        import org.wfmc.wapi.*;
0059:
0060:        import java.security.Principal;
0061:
0062:        /**
0063:         * Implements the RMI interface to the OBE API.
0064:         *
0065:         * @author Adrian Price.
0066:         * @ejb:bean type="Stateless"
0067:         * name="J2EEServer"
0068:         * display-name="OBE RMI Server"
0069:         * jndi-name="org/obe/ejb/J2EEServerRemote"
0070:         * local-jndi-name="org/obe/ejb/J2EEServerLocal"
0071:         * transaction-type="Container"
0072:         * view-type="both"
0073:         * @ejb:home extends="javax.ejb.EJBHome"
0074:         * local-extends="javax.ejb.EJBLocalHome"
0075:         * local-package="org.obe.client.api.local"
0076:         * remote-package="org.obe.client.api.rmi"
0077:         * @ejb:interface local-extends="org.obe.client.api.base.WorkflowEngineIntf,javax.ejb.EJBLocalObject"
0078:         * local-package="org.obe.client.api.local"
0079:         * extends="org.obe.client.api.base.WorkflowEngineIntf,javax.ejb.EJBObject"
0080:         * remote-package="org.obe.client.api.rmi"
0081:         * @ejb:security-identity description="OBE authorization relies upon J2EE security roles."
0082:         * use-caller-identity="true"
0083:         * @ejb:security-role-ref role-name="administrator"
0084:         * role-link="administrator"
0085:         * @ejb:security-role-ref role-name="designer"
0086:         * role-link="designer"
0087:         * @ejb:security-role-ref role-name="author"
0088:         * role-link="author"
0089:         * @ejb:security-role-ref role-name="manager"
0090:         * role-link="manager"
0091:         * @ejb:security-role-ref role-name="user"
0092:         * role-link="user"
0093:         * @ejb:transaction type="Required"
0094:         * @weblogic:transaction-isolation ${transaction.isolation}
0095:         * @ejb:resource-ref res-name="jdbc/TxDataSource"
0096:         * res-type="javax.sql.DataSource"
0097:         * res-auth="Container"
0098:         * @jboss:resource-manager res-man-class="javax.sql.DataSource"
0099:         * res-man-name="jdbc/TxDataSource"
0100:         * res-man-jndi-name="java:/${xdoclet.DataSource}"
0101:         * @weblogic:resource-description res-ref-name="jdbc/TxDataSource"
0102:         * jndi-name="${xdoclet.DataSource}"
0103:         * @ejb:resource-ref res-name="mail/Session"
0104:         * res-type="javax.mail.Session"
0105:         * res-auth="Container"
0106:         * @jboss:resource-manager res-man-class="javax.mail.Session"
0107:         * res-man-name="mail/Session"
0108:         * res-man-jndi-name="java:/${xdoclet.MailSession}"
0109:         * @weblogic:resource-description res-ref-name="mail/Session"
0110:         * jndi-name="${xdoclet.MailSession}"
0111:         * @ejb:resource-ref res-name="jms/AsyncRequestQueue"
0112:         * res-type="javax.jms.Queue"
0113:         * res-auth="Container"
0114:         * @jboss:resource-manager res-man-class="javax.jms.Queue"
0115:         * res-man-name="jms/AsyncRequestQueue"
0116:         * res-man-jndi-name="queue/${xdoclet.AsyncRequestQueue}"
0117:         * @weblogic:resource-description res-ref-name="jms/AsyncRequestQueue"
0118:         * jndi-name="${xdoclet.AsyncRequestQueue}"
0119:         * @weblogic:pool max-beans-in-free-pool="50"
0120:         * initial-beans-in-free-pool="0"
0121:         */
0122:        public class J2EEServerEJB extends AbstractSessionEJB {
0123:            private static final long serialVersionUID = -4323033653941168824L;
0124:            private static final String MANAGER = "manager";
0125:            private static final Log _logger = getLogger(J2EEServerEJB.class);
0126:            private static final WorkflowEngine _engine = J2EEServerConfig.engine;
0127:
0128:            public J2EEServerEJB() {
0129:            }
0130:
0131:            /**
0132:             * @ejb:create-method
0133:             * @ejb:permission role-name="user"
0134:             */
0135:            public void ejbCreate() {
0136:                if (_logger.isDebugEnabled() && ServerConfig.isVerbose())
0137:                    _logger.debug("ejbCreate()");
0138:            }
0139:
0140:            /**
0141:             * @ejb:permission role-name="user"
0142:             */
0143:            public void ejbRemove() {
0144:                super .ejbRemove();
0145:            }
0146:
0147:            /**
0148:             * @ejb:interface-method
0149:             * @ejb:permission role-name="author"
0150:             */
0151:            public WMProcessDefinition[] listProcessDefinitions(
0152:                    WMFilter filter, boolean countFlag)
0153:                    throws WMWorkflowException {
0154:
0155:                try {
0156:                    pushCallerPrincipal();
0157:                    return _engine.listProcessDefinitions(filter, countFlag);
0158:                } catch (WMWorkflowException e) {
0159:                    setRollbackOnly();
0160:                    throw e;
0161:                } finally {
0162:                    popCallerPrincipal();
0163:                }
0164:            }
0165:
0166:            /**
0167:             * @ejb:interface-method
0168:             * @ejb:permission role-name="author"
0169:             */
0170:            public WMProcessDefinitionState[] listProcessDefinitionStates(
0171:                    WMFilter filter, boolean countFlag)
0172:                    throws WMWorkflowException {
0173:
0174:                try {
0175:                    pushCallerPrincipal();
0176:                    return _engine.listProcessDefinitionStates(filter,
0177:                            countFlag);
0178:                } catch (WMWorkflowException e) {
0179:                    setRollbackOnly();
0180:                    throw e;
0181:                } finally {
0182:                    popCallerPrincipal();
0183:                }
0184:            }
0185:
0186:            /**
0187:             * @ejb:interface-method
0188:             * @ejb:permission role-name="administrator"
0189:             */
0190:            public void changeProcessDefinitionState(
0191:                    String processDefinitionId,
0192:                    WMProcessDefinitionState newState)
0193:                    throws WMWorkflowException {
0194:
0195:                try {
0196:                    pushCallerPrincipal();
0197:                    _engine.changeProcessDefinitionState(processDefinitionId,
0198:                            newState);
0199:                } catch (WMWorkflowException e) {
0200:                    setRollbackOnly();
0201:                    throw e;
0202:                } finally {
0203:                    popCallerPrincipal();
0204:                }
0205:            }
0206:
0207:            /**
0208:             * @ejb:interface-method
0209:             * @ejb:permission role-name="author"
0210:             */
0211:            public String createProcessInstance(String processDefinitionId,
0212:                    String processInstanceName) throws WMWorkflowException {
0213:
0214:                try {
0215:                    pushCallerPrincipal();
0216:                    return _engine.createProcessInstance(processDefinitionId,
0217:                            processInstanceName);
0218:                } catch (WMWorkflowException e) {
0219:                    setRollbackOnly();
0220:                    throw e;
0221:                } finally {
0222:                    popCallerPrincipal();
0223:                }
0224:            }
0225:
0226:            /**
0227:             * @ejb:interface-method
0228:             * @ejb:permission role-name="author"
0229:             */
0230:            public String createProcessInstanceVersioned(String name,
0231:                    String processInstanceName) throws WMWorkflowException {
0232:
0233:                try {
0234:                    pushCallerPrincipal();
0235:                    return _engine.createProcessInstanceVersioned(name,
0236:                            processInstanceName);
0237:                } catch (WMWorkflowException e) {
0238:                    setRollbackOnly();
0239:                    throw e;
0240:                } finally {
0241:                    popCallerPrincipal();
0242:                }
0243:            }
0244:
0245:            /**
0246:             * @ejb:interface-method
0247:             * @ejb:permission role-name="author"
0248:             */
0249:            public String startProcess(String processInstanceId)
0250:                    throws WMWorkflowException {
0251:
0252:                try {
0253:                    pushCallerPrincipal();
0254:                    return _engine.startProcess(processInstanceId);
0255:                } catch (WMWorkflowException e) {
0256:                    setRollbackOnly();
0257:                    throw e;
0258:                } finally {
0259:                    popCallerPrincipal();
0260:                }
0261:            }
0262:
0263:            /**
0264:             * @ejb:interface-method
0265:             * @ejb:permission role-name="administrator"
0266:             */
0267:            public void terminateProcessInstance(String processInstanceId)
0268:                    throws WMWorkflowException {
0269:
0270:                try {
0271:                    pushCallerPrincipal();
0272:                    _engine.terminateProcessInstance(processInstanceId);
0273:                } catch (WMWorkflowException e) {
0274:                    setRollbackOnly();
0275:                    throw e;
0276:                } finally {
0277:                    popCallerPrincipal();
0278:                }
0279:            }
0280:
0281:            /**
0282:             * @ejb:interface-method
0283:             * @ejb:permission role-name="administrator"
0284:             */
0285:            public void changeProcessInstanceState(String processInstanceId,
0286:                    WMProcessInstanceState newState) throws WMWorkflowException {
0287:
0288:                try {
0289:                    pushCallerPrincipal();
0290:                    _engine.changeProcessInstanceState(processInstanceId,
0291:                            newState);
0292:                } catch (WMWorkflowException e) {
0293:                    setRollbackOnly();
0294:                    throw e;
0295:                } finally {
0296:                    popCallerPrincipal();
0297:                }
0298:            }
0299:
0300:            /**
0301:             * @ejb:interface-method
0302:             * @ejb:permission role-name="administrator"
0303:             */
0304:            public WMProcessInstanceState[] listProcessInstanceStates(
0305:                    String processInstanceId, WMFilter filter, boolean countFlag)
0306:                    throws WMWorkflowException {
0307:
0308:                try {
0309:                    pushCallerPrincipal();
0310:                    return _engine.listProcessInstanceStates(processInstanceId,
0311:                            filter, countFlag);
0312:                } catch (WMWorkflowException e) {
0313:                    setRollbackOnly();
0314:                    throw e;
0315:                } finally {
0316:                    popCallerPrincipal();
0317:                }
0318:            }
0319:
0320:            /**
0321:             * @ejb:interface-method
0322:             * @ejb:permission role-name="user"
0323:             */
0324:            public WMAttribute[] listProcessInstanceAttributes(
0325:                    String processInstanceId, WMFilter filter, boolean countFlag)
0326:                    throws WMWorkflowException {
0327:
0328:                try {
0329:                    pushCallerPrincipal();
0330:                    return _engine.listProcessInstanceAttributes(
0331:                            processInstanceId, filter, countFlag);
0332:                } catch (WMWorkflowException e) {
0333:                    setRollbackOnly();
0334:                    throw e;
0335:                } finally {
0336:                    popCallerPrincipal();
0337:                }
0338:            }
0339:
0340:            /**
0341:             * @ejb:interface-method
0342:             * @ejb:permission role-name="user"
0343:             */
0344:            public WMAttribute getProcessInstanceAttributeValue(
0345:                    String processInstanceId, String attributeName)
0346:                    throws WMWorkflowException {
0347:
0348:                try {
0349:                    pushCallerPrincipal();
0350:                    return _engine.getProcessInstanceAttributeValue(
0351:                            processInstanceId, attributeName);
0352:                } catch (WMWorkflowException e) {
0353:                    setRollbackOnly();
0354:                    throw e;
0355:                } finally {
0356:                    popCallerPrincipal();
0357:                }
0358:            }
0359:
0360:            /**
0361:             * @ejb:interface-method
0362:             * @ejb:permission role-name="administrator"
0363:             */
0364:            public void assignProcessInstanceAttribute(
0365:                    String processInstanceId, String attributeName,
0366:                    Object attributeValue) throws WMWorkflowException {
0367:
0368:                try {
0369:                    pushCallerPrincipal();
0370:                    _engine.assignProcessInstanceAttribute(processInstanceId,
0371:                            attributeName, attributeValue);
0372:                } catch (WMWorkflowException e) {
0373:                    setRollbackOnly();
0374:                    throw e;
0375:                } finally {
0376:                    popCallerPrincipal();
0377:                }
0378:            }
0379:
0380:            /**
0381:             * @ejb:interface-method
0382:             * @ejb:permission role-name="user"
0383:             */
0384:            public WMActivityInstanceState[] listActivityInstanceStates(
0385:                    String processInstanceId, String activityInstanceId,
0386:                    WMFilter filter, boolean countFlag)
0387:                    throws WMWorkflowException {
0388:
0389:                try {
0390:                    pushCallerPrincipal();
0391:                    return _engine.listActivityInstanceStates(
0392:                            processInstanceId, activityInstanceId, filter,
0393:                            countFlag);
0394:                } catch (WMWorkflowException e) {
0395:                    setRollbackOnly();
0396:                    throw e;
0397:                } finally {
0398:                    popCallerPrincipal();
0399:                }
0400:            }
0401:
0402:            /**
0403:             * @ejb:interface-method
0404:             * @ejb:permission role-name="administrator"
0405:             */
0406:            public void changeActivityInstanceState(String processInstanceId,
0407:                    String activityInstanceId, WMActivityInstanceState newState)
0408:                    throws WMWorkflowException {
0409:
0410:                try {
0411:                    pushCallerPrincipal();
0412:                    _engine.changeActivityInstanceState(processInstanceId,
0413:                            activityInstanceId, newState);
0414:                } catch (WMWorkflowException e) {
0415:                    setRollbackOnly();
0416:                    throw e;
0417:                } finally {
0418:                    popCallerPrincipal();
0419:                }
0420:            }
0421:
0422:            /**
0423:             * @ejb:interface-method
0424:             * @ejb:permission role-name="user"
0425:             */
0426:            public WMAttribute[] listActivityInstanceAttributes(
0427:                    String processInstanceId, String activityInstanceId,
0428:                    WMFilter filter, boolean countFlag)
0429:                    throws WMWorkflowException {
0430:
0431:                try {
0432:                    pushCallerPrincipal();
0433:                    return _engine.listActivityInstanceAttributes(
0434:                            processInstanceId, activityInstanceId, filter,
0435:                            countFlag);
0436:                } catch (WMWorkflowException e) {
0437:                    setRollbackOnly();
0438:                    throw e;
0439:                } finally {
0440:                    popCallerPrincipal();
0441:                }
0442:            }
0443:
0444:            /**
0445:             * @ejb:interface-method
0446:             * @ejb:permission role-name="user"
0447:             */
0448:            public WMAttribute getActivityInstanceAttributeValue(
0449:                    String processInstanceId, String activityInstanceId,
0450:                    String attributeName) throws WMWorkflowException {
0451:
0452:                try {
0453:                    pushCallerPrincipal();
0454:                    return _engine.getActivityInstanceAttributeValue(
0455:                            processInstanceId, activityInstanceId,
0456:                            attributeName);
0457:                } catch (WMWorkflowException e) {
0458:                    setRollbackOnly();
0459:                    throw e;
0460:                } finally {
0461:                    popCallerPrincipal();
0462:                }
0463:            }
0464:
0465:            /**
0466:             * @ejb:interface-method
0467:             * @ejb:permission role-name="administrator"
0468:             */
0469:            public void assignActivityInstanceAttribute(
0470:                    String processInstanceId, String activityInstanceId,
0471:                    String attributeName, Object attributeValue)
0472:                    throws WMWorkflowException {
0473:
0474:                try {
0475:                    pushCallerPrincipal();
0476:                    _engine.assignActivityInstanceAttribute(processInstanceId,
0477:                            activityInstanceId, attributeName, attributeValue);
0478:                } catch (WMWorkflowException e) {
0479:                    setRollbackOnly();
0480:                    throw e;
0481:                } finally {
0482:                    popCallerPrincipal();
0483:                }
0484:            }
0485:
0486:            /**
0487:             * @ejb:interface-method
0488:             * @ejb:permission role-name="user"
0489:             */
0490:            public WMProcessInstance[] listProcessInstances(WMFilter filter,
0491:                    boolean countFlag) throws WMWorkflowException {
0492:
0493:                try {
0494:                    pushCallerPrincipal();
0495:                    return _engine.listProcessInstances(filter, countFlag);
0496:                } catch (WMWorkflowException e) {
0497:                    setRollbackOnly();
0498:                    throw e;
0499:                } finally {
0500:                    popCallerPrincipal();
0501:                }
0502:            }
0503:
0504:            /**
0505:             * @ejb:interface-method
0506:             * @ejb:permission role-name="user"
0507:             */
0508:            public WMProcessInstance getProcessInstance(String processInstanceId)
0509:                    throws WMWorkflowException {
0510:
0511:                try {
0512:                    pushCallerPrincipal();
0513:                    return _engine.getProcessInstance(processInstanceId);
0514:                } catch (WMWorkflowException e) {
0515:                    setRollbackOnly();
0516:                    throw e;
0517:                } finally {
0518:                    popCallerPrincipal();
0519:                }
0520:            }
0521:
0522:            /**
0523:             * @ejb:interface-method
0524:             * @ejb:permission role-name="user"
0525:             */
0526:            public WMActivityInstance[] listActivityInstances(WMFilter filter,
0527:                    boolean countFlag) throws WMWorkflowException {
0528:
0529:                try {
0530:                    pushCallerPrincipal();
0531:                    return _engine.listActivityInstances(filter, countFlag);
0532:                } catch (WMWorkflowException e) {
0533:                    setRollbackOnly();
0534:                    throw e;
0535:                } finally {
0536:                    popCallerPrincipal();
0537:                }
0538:            }
0539:
0540:            /**
0541:             * @ejb:interface-method
0542:             * @ejb:permission role-name="user"
0543:             */
0544:            public WMActivityInstance getActivityInstance(
0545:                    String processInstanceId, String activityInstanceId)
0546:                    throws WMWorkflowException {
0547:
0548:                try {
0549:                    pushCallerPrincipal();
0550:                    return _engine.getActivityInstance(processInstanceId,
0551:                            activityInstanceId);
0552:                } catch (WMWorkflowException e) {
0553:                    setRollbackOnly();
0554:                    throw e;
0555:                } finally {
0556:                    popCallerPrincipal();
0557:                }
0558:            }
0559:
0560:            /**
0561:             * @ejb:interface-method
0562:             * @ejb:permission role-name="user"
0563:             */
0564:            public WMWorkItem[] listWorkItems(WMFilter filter, boolean countFlag)
0565:                    throws WMWorkflowException {
0566:
0567:                try {
0568:                    Principal caller = pushCallerPrincipal();
0569:                    if (_logger.isDebugEnabled()) {
0570:                        _logger.debug("listWorkItems: caller = "
0571:                                + caller.getName());
0572:                        _logger
0573:                                .debug("listWorkItems: isCallerInRole(\"manager\") = "
0574:                                        + _ctx.isCallerInRole(MANAGER));
0575:                    }
0576:
0577:                    // Can only retrieve own workitems unless you're a manager.
0578:                    WMWorkItem[] workItems = _engine.listWorkItems(filter,
0579:                            countFlag);
0580:                    if (!_ctx.isCallerInRole(MANAGER)) {
0581:                        String callerName = caller.getName();
0582:                        for (int i = 0; i < workItems.length; i++) {
0583:                            WMWorkItem workItem = workItems[i];
0584:                            if (!workItem.getParticipant().getName().equals(
0585:                                    callerName)) {
0586:                                throw new SecurityException(
0587:                                        "Can only retrieve own work items");
0588:                            }
0589:                        }
0590:                    }
0591:                    return workItems;
0592:                } catch (WMWorkflowException e) {
0593:                    setRollbackOnly();
0594:                    throw e;
0595:                } finally {
0596:                    popCallerPrincipal();
0597:                }
0598:            }
0599:
0600:            /**
0601:             * @ejb:interface-method
0602:             * @ejb:permission role-name="user"
0603:             */
0604:            public WMWorkItem getWorkItem(String processInstanceId,
0605:                    String workItemId) throws WMWorkflowException {
0606:
0607:                try {
0608:                    // TODO: move fine-grained ATZ checks to WorkflowEngine if possible?
0609:                    Principal caller = pushCallerPrincipal();
0610:                    WMWorkItem wi = _engine.getWorkItem(processInstanceId,
0611:                            workItemId);
0612:                    if (!wi.getParticipant().getName().equals(caller.getName())
0613:                            && !_ctx.isCallerInRole(MANAGER)) {
0614:
0615:                        throw new SecurityException(
0616:                                "Can only retrieve own work items");
0617:                    }
0618:
0619:                    return wi;
0620:                } catch (WMWorkflowException e) {
0621:                    setRollbackOnly();
0622:                    throw e;
0623:                } finally {
0624:                    popCallerPrincipal();
0625:                }
0626:            }
0627:
0628:            /**
0629:             * @ejb:interface-method
0630:             * @ejb:permission role-name="user"
0631:             */
0632:            public void completeWorkItem(String processInstanceId,
0633:                    String workItemId) throws WMWorkflowException {
0634:
0635:                try {
0636:                    pushCallerPrincipal();
0637:                    // TODO: Only owners & Managers can complete work item.
0638:                    _engine.completeWorkItem(processInstanceId, workItemId);
0639:                } catch (WMWorkflowException e) {
0640:                    setRollbackOnly();
0641:                    throw e;
0642:                } finally {
0643:                    popCallerPrincipal();
0644:                }
0645:            }
0646:
0647:            /**
0648:             * @ejb:interface-method
0649:             * @ejb:permission role-name="manager"
0650:             */
0651:            public void reassignWorkItem(String sourceUser, String targetUser,
0652:                    String processInstanceId, String workItemId)
0653:                    throws WMWorkflowException {
0654:
0655:                try {
0656:                    pushCallerPrincipal();
0657:                    // TODO: Only owners & Managers can reassign work item.
0658:                    if (!_ctx.isCallerInRole(MANAGER)) {
0659:                        throw new SecurityException(
0660:                                "Only the manager role can reassign work items");
0661:                    }
0662:                    _engine.reassignWorkItem(sourceUser, targetUser,
0663:                            processInstanceId, workItemId);
0664:                } catch (WMWorkflowException e) {
0665:                    setRollbackOnly();
0666:                    throw e;
0667:                } finally {
0668:                    popCallerPrincipal();
0669:                }
0670:            }
0671:
0672:            /**
0673:             * @ejb:interface-method
0674:             * @ejb:permission role-name="user"
0675:             */
0676:            public WMWorkItemState[] listWorkItemStates(
0677:                    String processInstanceId, String workItemId,
0678:                    WMFilter filter, boolean countFlag)
0679:                    throws WMWorkflowException {
0680:
0681:                try {
0682:                    pushCallerPrincipal();
0683:                    // TODO: only work item owner and managers can change state.
0684:                    return _engine.listWorkItemStates(processInstanceId,
0685:                            workItemId, filter, countFlag);
0686:                } catch (WMWorkflowException e) {
0687:                    setRollbackOnly();
0688:                    throw e;
0689:                } finally {
0690:                    popCallerPrincipal();
0691:                }
0692:            }
0693:
0694:            /**
0695:             * @ejb:interface-method
0696:             * @ejb:permission role-name="user"
0697:             */
0698:            public void changeWorkItemState(String processInstanceId,
0699:                    String workItemId, WMWorkItemState newState)
0700:                    throws WMWorkflowException {
0701:
0702:                try {
0703:                    pushCallerPrincipal();
0704:                    // TODO: only work item owner and managers can change state.
0705:                    _engine.changeWorkItemState(processInstanceId, workItemId,
0706:                            newState);
0707:                } catch (WMWorkflowException e) {
0708:                    setRollbackOnly();
0709:                    throw e;
0710:                } finally {
0711:                    popCallerPrincipal();
0712:                }
0713:            }
0714:
0715:            /**
0716:             * @ejb:interface-method
0717:             * @ejb:permission role-name="user"
0718:             */
0719:            public WMAttribute[] listWorkItemAttributes(
0720:                    String processInstanceId, String workItemId,
0721:                    WMFilter filter, boolean countFlag)
0722:                    throws WMWorkflowException {
0723:
0724:                try {
0725:                    pushCallerPrincipal();
0726:                    return _engine.listWorkItemAttributes(processInstanceId,
0727:                            workItemId, filter, countFlag);
0728:                } catch (WMWorkflowException e) {
0729:                    setRollbackOnly();
0730:                    throw e;
0731:                } finally {
0732:                    popCallerPrincipal();
0733:                }
0734:            }
0735:
0736:            /**
0737:             * @ejb:interface-method
0738:             * @ejb:permission role-name="user"
0739:             */
0740:            public WMAttribute getWorkItemAttributeValue(
0741:                    String processInstanceId, String workItemId,
0742:                    String attributeName) throws WMWorkflowException {
0743:
0744:                try {
0745:                    pushCallerPrincipal();
0746:                    return _engine.getWorkItemAttributeValue(processInstanceId,
0747:                            workItemId, attributeName);
0748:                } catch (WMWorkflowException e) {
0749:                    setRollbackOnly();
0750:                    throw e;
0751:                } finally {
0752:                    popCallerPrincipal();
0753:                }
0754:            }
0755:
0756:            /**
0757:             * @ejb:interface-method
0758:             * @ejb:permission role-name="administrator"
0759:             * @ejb:permission role-name="user"
0760:             */
0761:            public void assignWorkItemAttribute(String processInstanceId,
0762:                    String workItemId, String attributeName,
0763:                    Object attributeValue) throws WMWorkflowException {
0764:
0765:                try {
0766:                    pushCallerPrincipal();
0767:                    _engine.assignWorkItemAttribute(processInstanceId,
0768:                            workItemId, attributeName, attributeValue);
0769:                } catch (WMWorkflowException e) {
0770:                    setRollbackOnly();
0771:                    throw e;
0772:                } finally {
0773:                    popCallerPrincipal();
0774:                }
0775:            }
0776:
0777:            /**
0778:             * @ejb:interface-method
0779:             * @ejb:permission role-name="administrator"
0780:             */
0781:            public void changeProcessInstancesState(String processDefinitionId,
0782:                    WMFilter filter, WMProcessInstanceState newState)
0783:                    throws WMWorkflowException {
0784:
0785:                try {
0786:                    pushCallerPrincipal();
0787:                    _engine.changeProcessInstancesState(processDefinitionId,
0788:                            filter, newState);
0789:                } catch (WMWorkflowException e) {
0790:                    setRollbackOnly();
0791:                    throw e;
0792:                } finally {
0793:                    popCallerPrincipal();
0794:                }
0795:            }
0796:
0797:            /**
0798:             * @ejb:interface-method
0799:             * @ejb:permission role-name="administrator"
0800:             */
0801:            public void changeActivityInstancesState(
0802:                    String processDefinitionId, String activityDefinitionId,
0803:                    WMFilter filter, WMActivityInstanceState newState)
0804:                    throws WMWorkflowException {
0805:
0806:                try {
0807:                    pushCallerPrincipal();
0808:                    _engine.changeActivityInstancesState(processDefinitionId,
0809:                            activityDefinitionId, filter, newState);
0810:                } catch (WMWorkflowException e) {
0811:                    setRollbackOnly();
0812:                    throw e;
0813:                } finally {
0814:                    popCallerPrincipal();
0815:                }
0816:            }
0817:
0818:            /**
0819:             * @ejb:interface-method
0820:             * @ejb:permission role-name="administrator"
0821:             */
0822:            public void terminateProcessInstances(String processDefinitionId,
0823:                    WMFilter filter) throws WMWorkflowException {
0824:
0825:                try {
0826:                    pushCallerPrincipal();
0827:                    _engine.terminateProcessInstances(processDefinitionId,
0828:                            filter);
0829:                } catch (WMWorkflowException e) {
0830:                    setRollbackOnly();
0831:                    throw e;
0832:                } finally {
0833:                    popCallerPrincipal();
0834:                }
0835:            }
0836:
0837:            /**
0838:             * @ejb:interface-method
0839:             * @ejb:permission role-name="administrator"
0840:             */
0841:            public void assignProcessInstancesAttribute(
0842:                    String processDefinitionId, WMFilter filter,
0843:                    String attributeName, Object attributeValue)
0844:                    throws WMWorkflowException {
0845:
0846:                try {
0847:                    pushCallerPrincipal();
0848:                    _engine.assignProcessInstancesAttribute(
0849:                            processDefinitionId, filter, attributeName,
0850:                            attributeValue);
0851:                } catch (WMWorkflowException e) {
0852:                    setRollbackOnly();
0853:                    throw e;
0854:                } finally {
0855:                    popCallerPrincipal();
0856:                }
0857:            }
0858:
0859:            /**
0860:             * @ejb:interface-method
0861:             * @ejb:permission role-name="administrator"
0862:             */
0863:            public void assignActivityInstancesAttribute(
0864:                    String processDefinitionId, String activityDefinitionId,
0865:                    WMFilter filter, String attributeName, Object attributeValue)
0866:                    throws WMWorkflowException {
0867:
0868:                try {
0869:                    pushCallerPrincipal();
0870:                    _engine.assignActivityInstancesAttribute(
0871:                            processDefinitionId, activityDefinitionId, filter,
0872:                            attributeName, attributeValue);
0873:                } catch (WMWorkflowException e) {
0874:                    setRollbackOnly();
0875:                    throw e;
0876:                } finally {
0877:                    popCallerPrincipal();
0878:                }
0879:            }
0880:
0881:            /**
0882:             * @ejb:interface-method
0883:             * @ejb:permission role-name="administrator"
0884:             */
0885:            public void abortProcessInstances(String processDefinitionId,
0886:                    WMFilter filter) throws WMWorkflowException {
0887:
0888:                try {
0889:                    pushCallerPrincipal();
0890:                    _engine.abortProcessInstances(processDefinitionId, filter);
0891:                } catch (WMWorkflowException e) {
0892:                    setRollbackOnly();
0893:                    throw e;
0894:                } finally {
0895:                    popCallerPrincipal();
0896:                }
0897:            }
0898:
0899:            /**
0900:             * @ejb:interface-method
0901:             * @ejb:permission role-name="administrator"
0902:             */
0903:            public void abortProcessInstance(String processInstanceId)
0904:                    throws WMWorkflowException {
0905:
0906:                try {
0907:                    pushCallerPrincipal();
0908:                    _engine.abortProcessInstance(processInstanceId);
0909:                } catch (WMWorkflowException e) {
0910:                    setRollbackOnly();
0911:                    throw e;
0912:                } finally {
0913:                    popCallerPrincipal();
0914:                }
0915:            }
0916:
0917:            /**
0918:             * @ejb:interface-method
0919:             * @ejb:permission role-name="designer"
0920:             */
0921:            public String createPackage(XPDLPackage pkg)
0922:                    throws WMWorkflowException {
0923:                try {
0924:                    pushCallerPrincipal();
0925:                    return _engine.createPackage(pkg);
0926:                } catch (WMWorkflowException e) {
0927:                    setRollbackOnly();
0928:                    throw e;
0929:                } finally {
0930:                    popCallerPrincipal();
0931:                }
0932:            }
0933:
0934:            /**
0935:             * @ejb:interface-method
0936:             * @ejb:permission role-name="designer"
0937:             */
0938:            public void updatePackage(XPDLPackage pkg)
0939:                    throws WMWorkflowException {
0940:                try {
0941:                    pushCallerPrincipal();
0942:                    _engine.updatePackage(pkg);
0943:                } catch (WMWorkflowException e) {
0944:                    setRollbackOnly();
0945:                    throw e;
0946:                } finally {
0947:                    popCallerPrincipal();
0948:                }
0949:            }
0950:
0951:            /**
0952:             * @ejb:interface-method
0953:             * @ejb:permission role-name="user"
0954:             */
0955:            public XPDLPackage getPackage(String packageId)
0956:                    throws WMWorkflowException {
0957:                try {
0958:                    pushCallerPrincipal();
0959:                    return _engine.getPackage(packageId);
0960:                } catch (WMWorkflowException e) {
0961:                    setRollbackOnly();
0962:                    throw e;
0963:                } finally {
0964:                    popCallerPrincipal();
0965:                }
0966:            }
0967:
0968:            /**
0969:             * @ejb:interface-method
0970:             * @ejb:permission role-name="designer"
0971:             */
0972:            public String createPackage(String content, String contentType)
0973:                    throws WMWorkflowException {
0974:
0975:                // TODO: use the factory pattern to handle content types.
0976:                // TODO: move content handling logic into the engine.
0977:                if (!contentType.equals(WMClient.XPDL))
0978:                    throw new WMUnsupportedOperationException(contentType);
0979:
0980:                try {
0981:                    pushCallerPrincipal();
0982:                    return _engine.createPackage(content, WMClient.XPDL);
0983:                } catch (WMWorkflowException e) {
0984:                    setRollbackOnly();
0985:                    throw e;
0986:                } finally {
0987:                    popCallerPrincipal();
0988:                }
0989:            }
0990:
0991:            /**
0992:             * @ejb:interface-method
0993:             * @ejb:permission role-name="user"
0994:             */
0995:            public String getPackageContent(String packageId, String contentType)
0996:                    throws WMWorkflowException {
0997:
0998:                try {
0999:                    pushCallerPrincipal();
1000:                    return _engine.getPackageContent(packageId, contentType);
1001:                } catch (WMWorkflowException e) {
1002:                    setRollbackOnly();
1003:                    throw e;
1004:                } finally {
1005:                    popCallerPrincipal();
1006:                }
1007:            }
1008:
1009:            /**
1010:             * @ejb:interface-method
1011:             * @ejb:permission role-name="designer"
1012:             */
1013:            public void setPackageContent(String packageId, String content,
1014:                    String contentType) throws WMWorkflowException {
1015:
1016:                try {
1017:                    pushCallerPrincipal();
1018:                    _engine.setPackageContent(packageId, content, contentType);
1019:                } catch (WMWorkflowException e) {
1020:                    setRollbackOnly();
1021:                    throw e;
1022:                } finally {
1023:                    popCallerPrincipal();
1024:                }
1025:            }
1026:
1027:            /**
1028:             * @ejb:interface-method
1029:             * @ejb:permission role-name="designer"
1030:             */
1031:            public void deletePackage(String packageId)
1032:                    throws WMWorkflowException {
1033:                try {
1034:                    pushCallerPrincipal();
1035:                    _engine.deletePackage(packageId);
1036:                } catch (WMWorkflowException e) {
1037:                    setRollbackOnly();
1038:                    throw e;
1039:                } finally {
1040:                    popCallerPrincipal();
1041:                }
1042:            }
1043:
1044:            /**
1045:             * @ejb:interface-method
1046:             * @ejb:permission role-name="administrator"
1047:             */
1048:            public void deleteProcessInstance(String processInstanceId)
1049:                    throws WMWorkflowException {
1050:
1051:                try {
1052:                    pushCallerPrincipal();
1053:                    _engine.deleteProcessInstance(processInstanceId);
1054:                } catch (WMWorkflowException e) {
1055:                    setRollbackOnly();
1056:                    throw e;
1057:                } finally {
1058:                    popCallerPrincipal();
1059:                }
1060:            }
1061:
1062:            /**
1063:             * @ejb:interface-method
1064:             * @ejb:permission role-name="administrator"
1065:             */
1066:            public void deleteProcessInstances(String processDefinitionId,
1067:                    WMFilter filter) throws WMWorkflowException {
1068:
1069:                try {
1070:                    pushCallerPrincipal();
1071:                    _engine.deleteProcessInstances(processDefinitionId, filter);
1072:                } catch (WMWorkflowException e) {
1073:                    setRollbackOnly();
1074:                    throw e;
1075:                } finally {
1076:                    popCallerPrincipal();
1077:                }
1078:            }
1079:
1080:            /**
1081:             * @ejb:interface-method
1082:             * @ejb:permission role-name="user"
1083:             */
1084:            public WMAAuditEntry[] listAuditEntries(WMFilter filter)
1085:                    throws WMWorkflowException {
1086:
1087:                try {
1088:                    pushCallerPrincipal();
1089:                    return _engine.listAuditEntries(filter);
1090:                } catch (WMWorkflowException e) {
1091:                    setRollbackOnly();
1092:                    throw e;
1093:                } finally {
1094:                    popCallerPrincipal();
1095:                }
1096:            }
1097:
1098:            /**
1099:             * @ejb:interface-method
1100:             * @ejb:permission role-name="administrator"
1101:             */
1102:            public int deleteAuditEntries(WMFilter filter)
1103:                    throws WMWorkflowException {
1104:                try {
1105:                    pushCallerPrincipal();
1106:                    return _engine.deleteAuditEntries(filter);
1107:                } catch (WMWorkflowException e) {
1108:                    setRollbackOnly();
1109:                    throw e;
1110:                } finally {
1111:                    popCallerPrincipal();
1112:                }
1113:            }
1114:
1115:            /**
1116:             * @ejb:interface-method view-type="local"
1117:             * @ejb:permission role-name="administrator"
1118:             */
1119:            public void raiseEvent(ApplicationEvent event,
1120:                    String[] correlationKeys) throws WMWorkflowException {
1121:
1122:                try {
1123:                    pushCallerPrincipal();
1124:                    _engine.raiseEvent(event, correlationKeys);
1125:                } catch (WMWorkflowException e) {
1126:                    setRollbackOnly();
1127:                    throw e;
1128:                } finally {
1129:                    popCallerPrincipal();
1130:                }
1131:            }
1132:
1133:            /**
1134:             * @ejb:interface-method view-type="local"
1135:             * @ejb:permission role-name="administrator"
1136:             */
1137:            public void refreshWorkItems(String processInstanceId)
1138:                    throws WMWorkflowException {
1139:
1140:                try {
1141:                    pushCallerPrincipal();
1142:                    _engine.refreshWorkItems(processInstanceId);
1143:                } catch (WMWorkflowException e) {
1144:                    setRollbackOnly();
1145:                    throw e;
1146:                } finally {
1147:                    popCallerPrincipal();
1148:                }
1149:            }
1150:
1151:            /**
1152:             * @ejb:interface-method
1153:             * @ejb:permission role-name="user"
1154:             */
1155:            public ToolInvocation[] executeWorkItem(String procInstId,
1156:                    String workItemId) throws WMWorkflowException {
1157:
1158:                try {
1159:                    pushCallerPrincipal();
1160:                    return _engine.executeWorkItem(procInstId, workItemId);
1161:                } catch (WMWorkflowException e) {
1162:                    setRollbackOnly();
1163:                    throw e;
1164:                } finally {
1165:                    popCallerPrincipal();
1166:                }
1167:            }
1168:
1169:            /**
1170:             * @ejb:interface-method
1171:             * @ejb:permission role-name="user"
1172:             */
1173:            public void toolStarted(String procInstId, String workItemId)
1174:                    throws WMWorkflowException {
1175:
1176:                try {
1177:                    pushCallerPrincipal();
1178:                    _engine.toolStarted(procInstId, workItemId);
1179:                } catch (WMWorkflowException e) {
1180:                    setRollbackOnly();
1181:                    throw e;
1182:                } finally {
1183:                    popCallerPrincipal();
1184:                }
1185:            }
1186:
1187:            /**
1188:             * @ejb:interface-method
1189:             * @ejb:permission role-name="user"
1190:             */
1191:            public void toolFinished(String procInstId, String workItemId,
1192:                    int appStatus, Parameter[] parms)
1193:                    throws WMWorkflowException {
1194:
1195:                try {
1196:                    pushCallerPrincipal();
1197:                    _engine.toolFinished(procInstId, workItemId, appStatus,
1198:                            parms);
1199:                } catch (WMWorkflowException e) {
1200:                    setRollbackOnly();
1201:                    throw e;
1202:                } finally {
1203:                    popCallerPrincipal();
1204:                }
1205:            }
1206:
1207:            protected Log getLogger() {
1208:                return _logger;
1209:            }
1210:
1211:            private Principal pushCallerPrincipal() {
1212:                Principal caller = null;
1213:                String name = null;
1214:                try {
1215:                    caller = _ctx.getCallerPrincipal();
1216:                    name = caller.getName();
1217:
1218:                    if (_logger.isDebugEnabled())
1219:                        _logger.debug("Pushing caller context: " + name);
1220:                } catch (IllegalStateException e) {
1221:                    _logger
1222:                            .warn("Unauthenticated access - no security context is set");
1223:                } catch (Exception e) {
1224:                    _logger.error("Unable to determine security context", e);
1225:                    // Ignore exceptions thrown from getCallerPrincipal().  It just
1226:                    // means there's no security context configured.
1227:                } finally {
1228:                    // TODO: Fix this security hole.  Anyone can push a new NDC.
1229:                    NDC.push(name);
1230:                }
1231:                return caller;
1232:            }
1233:
1234:            private void popCallerPrincipal() {
1235:                NDC.pop();
1236:            }
1237:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.