Source Code Cross Referenced for StateManager.java in  » XML-UI » xui32 » com » xoetrope » service » 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 » XML UI » xui32 » com.xoetrope.service 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package com.xoetrope.service;
002:
003:        import java.io.StringReader;
004:        import java.io.StringWriter;
005:        import net.xoetrope.data.XDataSource;
006:        import net.xoetrope.optional.data.XOptionalDataSource;
007:        import net.xoetrope.optional.service.*;
008:        import net.xoetrope.xml.XmlElement;
009:        import net.xoetrope.xml.XmlSource;
010:        import net.xoetrope.xui.XProject;
011:        import net.xoetrope.xui.XProjectManager;
012:        import net.xoetrope.xui.data.XBaseModel;
013:        import net.xoetrope.xui.data.XModel;
014:
015:        /**
016:         *
017:         * <p> Copyright (c) Xoetrope Ltd., 2001-2006, This software is licensed under
018:         * the GNU Public License (GPL), please see license.txt for more details. If
019:         * you make commercial use of this software you must purchase a commercial
020:         * license from Xoetrope.</p>
021:         * <p> $Revision: 1.7 $</p>
022:         */
023:        public class StateManager extends ServiceProxy {
024:            public static final String ARG_NAME_MODELPATH = "modelpath";
025:            public static final String ARG_NAME_OUTPUTPARAM = "outputparam";
026:            public static final String ARG_NAME_OPERATION = "stateoperation";
027:
028:            public static final String ARG_VALUE_MODELOUTPUT = "stateoutput";
029:            public static final String ARG_VALUE_MODELRESTORE = "staterestore";
030:
031:            public static final String ARG_ERROR_CANNOT_PARSE_DATA = "Cannot parse the provided data.";
032:
033:            /**
034:             * The owner project and the context in which this object operates.
035:             */
036:            protected XProject currentProject = XProjectManager
037:                    .getCurrentProject();
038:            private XModel rootMdl = XProjectManager.getModel();
039:
040:            /**
041:             * The overloaded call for the ServiceProxy
042:             * @param method the name of the service
043:             * @param context the context object of the call
044:             */
045:            public Object call(String method, ServiceContext context) {
046:                ServiceProxyArgs args = context.getArgs();
047:                String mode = (String) args.getPassParam(ARG_NAME_OPERATION);
048:                String modelPath = (String) args
049:                        .getPassParam(ARG_NAME_MODELPATH);
050:                try {
051:                    Object ret = null;
052:                    String outputParam = (String) args
053:                            .getPassParam(ARG_NAME_OUTPUTPARAM);
054:                    if (side == XRouteManager.SERVER_SIDE) {
055:                        ret = callNextProxy(method, context, null);
056:                        if (mode.compareTo(ARG_VALUE_MODELRESTORE) == 0)
057:                            outputModel(context, outputParam, modelPath);
058:                    } else {
059:                        if (mode.compareTo(ARG_VALUE_MODELRESTORE) == 0) {
060:                            // The file is being opened so the returned content needs to populate the model
061:                            ((XBaseModel) rootMdl.get("xui_state/" + modelPath))
062:                                    .clear();
063:                            ((XBaseModel) rootMdl.get(modelPath)).clear();
064:
065:                            ret = callNextProxy(method, context, null);
066:                            restoreModel(context, outputParam);
067:                        } else if (mode.compareTo(ARG_VALUE_MODELOUTPUT) == 0) {
068:                            //The file is being saved and the contents of the target model need to be output
069:                            outputModel(context, outputParam, modelPath);
070:                            ret = callNextProxy(method, context, null);
071:                        }
072:                    }
073:                    return ret;
074:                } catch (ServiceProxyException e) {
075:                    return null;
076:                }
077:            }
078:
079:            private void restoreModel(ServiceContext context, String outputParam) {
080:                ServiceProxyArgs args = context.getArgs();
081:                String contents = (String) args.getReturnParam(outputParam);
082:                try {
083:                    StringReader sr = new StringReader(contents);
084:                    XmlElement ele = XmlSource.read(sr);
085:
086:                    if (ele != null) {
087:                        XOptionalDataSource ds = new XOptionalDataSource(
088:                                currentProject);
089:                        ds.loadTable(ele, rootMdl);
090:                        ds.loadTable(ele, (XModel) rootMdl.get("xui_state"));
091:                    }
092:                } catch (Exception e) {
093:                    context.getArgs().addError(ARG_ERROR_CANNOT_PARSE_DATA);
094:                }
095:            }
096:
097:            private void outputModel(ServiceContext context,
098:                    String outputParam, String modelPath) {
099:                ServiceProxyArgs args = context.getArgs();
100:                XBaseModel mdl = (XBaseModel) currentProject.getModel().get(
101:                        modelPath);
102:                StringWriter sw = new StringWriter();
103:                XDataSource.outputModel(sw, mdl);
104:                if (side == XRouteManager.CLIENT_SIDE)
105:                    args.setPassParam(outputParam, "<Datasets>" + sw.toString()
106:                            + "</Datasets>");
107:                else
108:                    args.setReturnParam(outputParam, "<Datasets>"
109:                            + sw.toString() + "</Datasets>");
110:            }
111:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.