Source Code Cross Referenced for WorkflowableWrapper.java in  » Content-Management-System » apache-lenya-2.0 » org » apache » lenya » cms » workflow » usecases » 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 » Content Management System » apache lenya 2.0 » org.apache.lenya.cms.workflow.usecases 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Licensed to the Apache Software Foundation (ASF) under one or more
003:         *  contributor license agreements.  See the NOTICE file distributed with
004:         *  this work for additional information regarding copyright ownership.
005:         *  The ASF licenses this file to You under the Apache License, Version 2.0
006:         *  (the "License"); you may not use this file except in compliance with
007:         *  the License.  You may obtain a copy of the License at
008:         *
009:         *      http://www.apache.org/licenses/LICENSE-2.0
010:         *
011:         *  Unless required by applicable law or agreed to in writing, software
012:         *  distributed under the License is distributed on an "AS IS" BASIS,
013:         *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         *  See the License for the specific language governing permissions and
015:         *  limitations under the License.
016:         *
017:         */
018:        package org.apache.lenya.cms.workflow.usecases;
019:
020:        import java.util.Arrays;
021:        import java.util.SortedSet;
022:        import java.util.TreeSet;
023:
024:        import org.apache.avalon.framework.container.ContainerUtil;
025:        import org.apache.avalon.framework.logger.AbstractLogEnabled;
026:        import org.apache.avalon.framework.logger.Logger;
027:        import org.apache.avalon.framework.service.ServiceManager;
028:        import org.apache.lenya.cms.publication.Document;
029:        import org.apache.lenya.cms.publication.DocumentException;
030:        import org.apache.lenya.cms.repository.Session;
031:        import org.apache.lenya.cms.workflow.WorkflowUtil;
032:        import org.apache.lenya.workflow.Workflow;
033:        import org.apache.lenya.workflow.WorkflowException;
034:        import org.apache.lenya.workflow.Workflowable;
035:
036:        /**
037:         * Wrap a workflowable for easy evaluation in JX template.
038:         */
039:        public class WorkflowableWrapper extends AbstractLogEnabled {
040:
041:            private MultiWorkflow usecase;
042:            private Workflowable workflowable;
043:            private ServiceManager manager;
044:            private Document document;
045:            private Session session;
046:
047:            /**
048:             * Ctor.
049:             * @param usecase The usecase.
050:             * @param manager The service manager.
051:             * @param session The session.
052:             * @param document The document to wrap.
053:             * @param logger The logger.
054:             */
055:            public WorkflowableWrapper(MultiWorkflow usecase,
056:                    ServiceManager manager, Session session, Document document,
057:                    Logger logger) {
058:                this .usecase = usecase;
059:                this .document = document;
060:                this .manager = manager;
061:                this .session = session;
062:                ContainerUtil.enableLogging(this , logger);
063:            }
064:
065:            protected Workflowable getWorkflowable() {
066:                if (this .workflowable == null) {
067:                    this .workflowable = WorkflowUtil.getWorkflowable(
068:                            this .manager, this .session, getLogger(),
069:                            this .document);
070:                }
071:                return this .workflowable;
072:            }
073:
074:            /**
075:             * @return The state of the latest version.
076:             * @throws WorkflowException
077:             */
078:            public String getState() throws WorkflowException {
079:                String state;
080:                if (getWorkflowable().getVersions().length > 0) {
081:                    state = getWorkflowable().getLatestVersion().getState();
082:                } else {
083:                    Workflow workflow = getWorkflowSchema();
084:                    state = workflow.getInitialState();
085:                }
086:                return state;
087:            }
088:
089:            /**
090:             * @return All states supported by the workflow schema.
091:             * @throws WorkflowException
092:             */
093:            public String[] getStates() throws WorkflowException {
094:                return getWorkflowSchema().getStates();
095:            }
096:
097:            protected Workflow getWorkflowSchema() throws WorkflowException {
098:                Workflow workflow = WorkflowUtil.getWorkflowSchema(
099:                        this .manager, this .session, getLogger(), this .document);
100:                return workflow;
101:            }
102:
103:            /**
104:             * @return The path of the document.
105:             * @throws DocumentException If the document is not referenced in the site
106:             *         structure.
107:             */
108:            public String getPath() throws DocumentException {
109:                return this .document.getPath();
110:            }
111:
112:            /**
113:             * @return The language of the document.
114:             */
115:            public String getLanguage() {
116:                return this .document.getLanguage();
117:            }
118:
119:            /**
120:             * @return The web application URL of the document.
121:             */
122:            public String getUrl() {
123:                return this .document.getCanonicalWebappURL();
124:            }
125:
126:            /**
127:             * @return All executable events in alphabetical order.
128:             * @throws WorkflowException if an error occurs.
129:             */
130:            public String[] getUsecases() throws WorkflowException {
131:                SortedSet usecases = new TreeSet();
132:                String[] events = getWorkflowSchema().getEvents();
133:                for (int i = 0; i < events.length; i++) {
134:                    if (WorkflowUtil.canInvoke(this .manager, this .session,
135:                            getLogger(), this .document, events[i])) {
136:                        String[] eventUsecases = this .usecase
137:                                .getUsecases(events[i]);
138:                        usecases.addAll(Arrays.asList(eventUsecases));
139:                    }
140:                }
141:
142:                return (String[]) usecases.toArray(new String[usecases.size()]);
143:            }
144:
145:            /**
146:             * @return The languages of the document in alphabetical order.
147:             * @throws DocumentException 
148:             */
149:            public String[] getLanguages() throws DocumentException {
150:                String[] languages = this.document.getLanguages();
151:                Arrays.sort(languages);
152:                return languages;
153:            }
154:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.