Source Code Cross Referenced for RemoteWorkspace.java in  » Workflow-Engines » OSWorkflow » com » opensymphony » workflow » loader » 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 » OSWorkflow » com.opensymphony.workflow.loader 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package com.opensymphony.workflow.loader;
002:
003:        import java.io.*;
004:        import java.util.*;
005:
006:        import com.opensymphony.workflow.FactoryException;
007:        import com.opensymphony.workflow.designer.Layout;
008:        import com.opensymphony.workflow.designer.ResourceManager;
009:        import com.opensymphony.workflow.designer.WorkflowGraph;
010:        import com.opensymphony.workflow.designer.DesignerService;
011:
012:        /**
013:         * @author Hani Suleiman (hani@formicary.net)
014:         * Date: May 15, 2003
015:         * Time: 7:56:36 PM
016:         */
017:        public class RemoteWorkspace extends HTTPWorkflowFactory {
018:            private Map layouts = new HashMap();
019:            private DesignerService service = null;
020:
021:            public RemoteWorkspace(DesignerService service) {
022:                this .service = service;
023:                workflows = new HashMap();
024:            }
025:
026:            public boolean isModifiable(String name) {
027:                return true;
028:            }
029:
030:            public void initDone() throws FactoryException {
031:                super .initDone();
032:
033:                Map flows = service.getWorkflows();
034:                Iterator iter = flows.entrySet().iterator();
035:                while (iter.hasNext()) {
036:                    Map.Entry entry = (Map.Entry) iter.next();
037:                    HTTPWorkflowConfig config = new HTTPWorkflowConfig(service
038:                            .getRemoteAddress(), entry.getValue().toString(),
039:                            entry.getKey().toString());
040:                    workflows.put(entry.getValue(), config);
041:                }
042:
043:                //	now read in all layouts
044:                iter = workflows.entrySet().iterator();
045:                while (iter.hasNext()) {
046:                    Map.Entry entry = (Map.Entry) iter.next();
047:                    String workflowName = entry.getKey().toString();
048:                    HTTPWorkflowConfig config = (HTTPWorkflowConfig) entry
049:                            .getValue();
050:                    String docId = config.docId;
051:                    layouts.put(workflowName, docId);
052:                }
053:            }
054:
055:            public String getName() {
056:                return service.getWorkspaceName();
057:            }
058:
059:            public boolean isNew() {
060:                //return workflowsXML==null;
061:                return false;
062:            }
063:
064:            public void importDescriptor(String name, InputStream is) {
065:                /*
066:                WorkflowConfig config = new WorkflowConfig("file", name + ".xml");
067:                try
068:                {
069:                  File file = new File(workflowsXML.getParentFile(), name+".xml");
070:                  config.url = file.toURL();
071:                  config.lastModified = file.lastModified();
072:                  workflows.put(name, config);
073:                }
074:                catch(MalformedURLException e)
075:                {
076:                  //can't really happen
077:                  e.printStackTrace();
078:                }
079:                 */
080:            }
081:
082:            public Object getLayout(String workflowName) {
083:                Object obj = layouts.get(workflowName);
084:                if (obj == null)
085:                    return null;
086:                if (obj instanceof  Layout)
087:                    return (Layout) obj;
088:                String docId = obj.toString();
089:                try {
090:                    String layBuffer = readLayoutBuffer(service
091:                            .getRemoteAddress(), docId);
092:                    if (layBuffer != null) {
093:                        Layout layout = new Layout(layBuffer);
094:                        layouts.put(workflowName, layout);
095:                        return layout;
096:                    }
097:                } catch (Exception e) {
098:                    e.printStackTrace();
099:                }
100:                return null;
101:            }
102:
103:            public void save() {
104:            }
105:
106:            public boolean removeWorkflow(String name) throws FactoryException {
107:                HTTPWorkflowConfig removed = (HTTPWorkflowConfig) workflows
108:                        .remove(name);
109:                save();
110:                return removed != null;
111:            }
112:
113:            public WorkflowDescriptor getWorkflow(String name, boolean validate)
114:                    throws FactoryException {
115:                HTTPWorkflowConfig config = (HTTPWorkflowConfig) workflows
116:                        .get(name);
117:                if (config == null)
118:                    return null;
119:
120:                if (config.descriptor == null) {
121:                    String docId = config.docId;
122:                    try {
123:                        String workflowBuffer = readWorkflowBuffer(service
124:                                .getRemoteAddress(), docId);
125:                        if (workflowBuffer != null) {
126:                            config.descriptor = WorkflowLoader.load(
127:                                    new ByteArrayInputStream(workflowBuffer
128:                                            .getBytes()), validate);
129:                            if (config.descriptor != null) {
130:                                /*
131:                                String metaName = (String)config.descriptor.getMetaAttributes().get("descr"); 
132:                                if ((metaName!=null)&&(metaName.length()>0))
133:                                	name = metaName;
134:                                 */
135:                                config.descriptor.setName(name);
136:                            }
137:                            return config.descriptor;
138:                        }
139:                    } catch (Exception e) {
140:                        e.printStackTrace();
141:                    }
142:                    return null;
143:                }
144:                return config.descriptor;
145:            }
146:
147:            public boolean saveWorkflow(String name,
148:                    WorkflowDescriptor descriptor, WorkflowGraph graph,
149:                    boolean replace) throws Exception {
150:                String layoutBuffer = "";
151:                String workflowBuffer;
152:
153:                Object obj = layouts.get(name);
154:                if (obj instanceof  Layout) {
155:                    Layout layout = (Layout) obj;
156:                    try {
157:                        HTTPWorkflowConfig config = (HTTPWorkflowConfig) workflows
158:                                .get(name);
159:
160:                        StringWriter sw = new StringWriter();
161:                        PrintWriter out = new PrintWriter(
162:                                new BufferedWriter(sw));
163:                        //PrintWriter out = new PrintWriter(new ByteArrayOutputStream());
164:                        layout.writeXML(out, 0, graph);
165:                        out.flush();
166:                        out.close();
167:                        layoutBuffer = sw.getBuffer().toString();
168:                        //layoutBuffer = out.toString(); 
169:                    } catch (Exception e) {
170:                        e.printStackTrace();
171:                        return false;
172:                    }
173:                }
174:                if (descriptor != null) {
175:                    HTTPWorkflowConfig config = (HTTPWorkflowConfig) workflows
176:                            .get(name);
177:                    descriptor.getMetaAttributes().put("generator",
178:                            "OSWOrkflow Designer");
179:                    descriptor.getMetaAttributes().put("lastModified",
180:                            (new Date()).toString());
181:                    StringWriter sw = new StringWriter();
182:                    PrintWriter writer = new PrintWriter(new BufferedWriter(sw));
183:                    writer.println(WorkflowDescriptor.XML_HEADER);
184:                    writer.println(WorkflowDescriptor.DOCTYPE_DECL);
185:                    descriptor.writeXML(writer, 0);
186:                    writer.flush();
187:                    writer.close();
188:                    //workflowBuffer = writer.toString();
189:                    workflowBuffer = sw.getBuffer().toString();
190:                    String ret = writeWorkflowDescriptor(service
191:                            .getRemoteAddress(), config.docId, name,
192:                            workflowBuffer);
193:                    System.out.println("workflow ret = " + ret);
194:                    if (ret.length() == 0)
195:                        return false;
196:                    ret = writeWorkflowLayout(service.getRemoteAddress(),
197:                            config.docId, name, layoutBuffer);
198:                    System.out.println("layout ret = " + ret);
199:                    if (ret.length() == 0)
200:                        return false;
201:                    config.docId = ret; // set the new document ID
202:                    return true;
203:                }
204:                return false;
205:            }
206:
207:            public void setLayout(String workflowName, Object layout) {
208:                layouts.put(workflowName, layout);
209:            }
210:
211:            /*
212:            public String getLocation()
213:            {
214:            //return workflowsXML;
215:            return null;
216:            }
217:
218:            public void setLocation(String service)
219:            {
220:            this.workflowsXML = new File(file.getParentFile(), "workflows.xml");
221:            this.configFile = file; 
222:            }
223:             */
224:
225:            public void createWorkflow(String name) {
226:                HTTPWorkflowConfig config = new HTTPWorkflowConfig(service
227:                        .getRemoteAddress(), name, "");
228:                config.descriptor = new WorkflowDescriptor();
229:                config.descriptor.setName(name);
230:                ActionDescriptor initialAction = new ActionDescriptor();
231:                initialAction.setName(ResourceManager
232:                        .getString("action.initial.start"));
233:                config.descriptor.getInitialActions().add(initialAction);
234:                config.descriptor.getMetaAttributes().put("created",
235:                        (new Date()).toString());
236:                workflows.put(name, config);
237:            }
238:
239:            public void renameWorkflow(String oldName, String newName) {
240:                //todo need to keep track of deleted workflows and delete their files on save
241:                HTTPWorkflowConfig config = (HTTPWorkflowConfig) workflows
242:                        .get(oldName);
243:                config.name = newName;
244:                workflows.remove(oldName);
245:                workflows.put(newName, config);
246:            }
247:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.