Source Code Cross Referenced for ImportHelper.java in  » IDE-Netbeans » bpel » org » netbeans » modules » bpel » model » api » support » 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 » IDE Netbeans » bpel » org.netbeans.modules.bpel.model.api.support 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * The contents of this file are subject to the terms of the Common Development
003:         * and Distribution License (the License). You may not use this file except in
004:         * compliance with the License.
005:         * 
006:         * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
007:         * or http://www.netbeans.org/cddl.txt.
008:         * 
009:         * When distributing Covered Code, include this CDDL Header Notice in each file
010:         * and include the License file at http://www.netbeans.org/cddl.txt.
011:         * If applicable, add the following below the CDDL Header, with the fields
012:         * enclosed by brackets [] replaced by your own identifying information:
013:         * "Portions Copyrighted [year] [name of copyright owner]"
014:         * 
015:         * The Original Software is NetBeans. The Initial Developer of the Original
016:         * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
017:         * Microsystems, Inc. All Rights Reserved.
018:         */
019:        package org.netbeans.modules.bpel.model.api.support;
020:
021:        import java.net.URI;
022:        import java.net.URISyntaxException;
023:        import java.util.Collection;
024:        import java.util.LinkedList;
025:
026:        import org.netbeans.modules.bpel.model.api.BpelModel;
027:        import org.netbeans.modules.bpel.model.api.Import;
028:        import org.netbeans.modules.xml.schema.model.Schema;
029:        import org.netbeans.modules.xml.schema.model.SchemaModel;
030:        import org.netbeans.modules.xml.schema.model.SchemaModelFactory;
031:        import org.netbeans.modules.xml.wsdl.model.Types;
032:        import org.netbeans.modules.xml.wsdl.model.WSDLModel;
033:        import org.netbeans.modules.xml.wsdl.model.WSDLModelFactory;
034:        import org.netbeans.modules.xml.xam.Model;
035:        import org.netbeans.modules.xml.xam.ModelSource;
036:        import org.netbeans.modules.xml.xam.locator.CatalogModelException;
037:        import org.netbeans.modules.xml.xam.locator.CatalogModelFactory;
038:
039:        /**
040:         * Helper class for accessing to WSDL or XSD models by import statement.
041:         * @author ads
042:         */
043:        public final class ImportHelper {
044:
045:            /**
046:             * This is helper class, we don't want its instance.  
047:             */
048:            private ImportHelper() {
049:            }
050:
051:            /**
052:             * Returns wsdl model respectively given import <code>imp</code>.
053:             * @param model BPEL OM
054:             * @param location location uri
055:             * @param importType type of import
056:             * 
057:             */
058:            public static WSDLModel getWsdlModel(BpelModel model,
059:                    String location, String importType) {
060:                return getWsdlModel(model, location, importType, true);
061:            }
062:
063:            /**
064:             * Returns wsdl model respectively given import <code>imp</code>.
065:             * @param model BPEL OM
066:             * @param location location uri
067:             * @param importType type of import
068:             * @param checkWellFormed if true method will return null if model is not valid
069:             */
070:            public static WSDLModel getWsdlModel(BpelModel model,
071:                    String location, String importType, boolean checkWellFormed)
072:
073:            {
074:                if (!Import.WSDL_IMPORT_TYPE.equals(importType)) {
075:                    return null;
076:                }
077:                WSDLModel wsdlModel;
078:                if (location == null) {
079:                    return null;
080:                }
081:                try {
082:                    URI uri = new URI(location);
083:                    ModelSource source = CatalogModelFactory.getDefault()
084:                            .getCatalogModel(model.getModelSource())
085:                            .getModelSource(uri, model.getModelSource());
086:                    wsdlModel = WSDLModelFactory.getDefault().getModel(source);
087:                } catch (URISyntaxException e) {
088:                    wsdlModel = null;
089:                } catch (CatalogModelException e) {
090:                    wsdlModel = null;
091:                }
092:                if (wsdlModel != null
093:                        && wsdlModel.getState() == Model.State.NOT_WELL_FORMED
094:                        && checkWellFormed) {
095:                    return null;
096:                }
097:                return wsdlModel;
098:            }
099:
100:            /**
101:             * Returns wsdl model respectively given import <code>imp</code>.
102:             * @param imp import statement in BPEL OM
103:             */
104:            public static WSDLModel getWsdlModel(Import imp) {
105:                return getWsdlModel(imp, true);
106:            }
107:
108:            /**
109:             * Returns wsdl model respectively given import <code>imp</code>.
110:             * @param imp import statement in BPEL OM
111:             * @param checkWellFormed if true method will return null if model is not valid 
112:             */
113:            public static WSDLModel getWsdlModel(Import imp,
114:                    boolean checkWellFormed) {
115:                return getWsdlModel(imp.getBpelModel(), imp.getLocation(), imp
116:                        .getImportType(), checkWellFormed);
117:            }
118:
119:            /**
120:             * Returns schema model respectively <code>imp</code> import
121:             * statement in BPEL OM and <code>namespace</code>.
122:             * @param bpelModel BPEL OM
123:             * @param location location uri
124:             * @param importType type of import
125:             * @param namespace schema namespace
126:             */
127:            public static Collection<SchemaModel> getInlineSchema(
128:                    BpelModel bpelModel, String namespace, String location,
129:                    String importType) {
130:                WSDLModel model = getWsdlModel(bpelModel, location, importType);
131:                if (model == null) {
132:                    return null;
133:                }
134:                Types types = model.getDefinitions().getTypes();
135:                if (types == null) {
136:                    return null;
137:                }
138:                Collection<Schema> collection = types.getSchemas();
139:                Collection<SchemaModel> models = null;
140:                for (Schema schema : collection) {
141:                    if (namespace.equals(schema.getTargetNamespace())) {
142:                        if (models == null) {
143:                            models = new LinkedList<SchemaModel>();
144:                        }
145:                        models.add(schema.getModel());
146:                    }
147:                }
148:                return models;
149:            }
150:
151:            /**
152:             * Returns schema model respectively <code>imp</code> import
153:             * statement in BPEL OM and <code>namespace</code>.
154:             * @param imp import statement in BPEL OM
155:             * @param namespace Namespace for desired inline schema model
156:             */
157:            public static Collection<SchemaModel> getInlineSchema(Import imp,
158:                    String namespace) {
159:                return getInlineSchema(imp.getBpelModel(), namespace, imp
160:                        .getLocation(), imp.getImportType());
161:            }
162:
163:            /**
164:             * Returns schema model respectively given import <code>imp</code>.
165:             * @param model BPEL OM
166:             * @param location location uri
167:             * @param importType type of import
168:             */
169:            public static SchemaModel getSchemaModel(BpelModel model,
170:                    String location, String importType) {
171:                return getSchemaModel(model, location, importType, true);
172:            }
173:
174:            /**
175:             * Returns schema model respectively given import <code>imp</code>.
176:             * @param model BPEL OM
177:             * @param location location uri
178:             * @param importType type of import
179:             */
180:            public static SchemaModel getSchemaModel(BpelModel model,
181:                    String location, String importType, boolean checkWellFormed) {
182:                if (!Import.SCHEMA_IMPORT_TYPE.equals(importType)) {
183:                    return null;
184:                }
185:                SchemaModel schemaModel;
186:                if (location == null) {
187:                    return null;
188:                }
189:                try {
190:                    URI uri = new URI(location);
191:                    ModelSource modelSource = CatalogModelFactory.getDefault()
192:                            .getCatalogModel(model.getModelSource())
193:                            .getModelSource(uri, model.getModelSource());
194:
195:                    schemaModel = SchemaModelFactory.getDefault().getModel(
196:                            modelSource);
197:                } catch (URISyntaxException e) {
198:                    schemaModel = null;
199:                } catch (CatalogModelException e) {
200:                    schemaModel = null;
201:                }
202:                if (schemaModel != null
203:                        && schemaModel.getState() == Model.State.NOT_WELL_FORMED
204:                        && checkWellFormed) {
205:                    schemaModel = null;
206:                }
207:                return schemaModel;
208:            }
209:
210:            /**
211:             * Returns schema model respectively given import <code>imp</code>.
212:             * @param imp import statement in BPEL OM
213:             */
214:            public static SchemaModel getSchemaModel(Import imp,
215:                    boolean checkWellFormed) {
216:                return getSchemaModel(imp.getBpelModel(), imp.getLocation(),
217:                        imp.getImportType(), checkWellFormed);
218:            }
219:
220:            /**
221:             * Returns schema model respectively given import <code>imp</code>.
222:             * @param imp import statement in BPEL OM
223:             */
224:            public static SchemaModel getSchemaModel(Import imp) {
225:                return getSchemaModel(imp.getBpelModel(), imp.getLocation(),
226:                        imp.getImportType());
227:            }
228:        }
w_w_w___.___j__a_v___a___2s___._c__o__m__ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.