Source Code Cross Referenced for CasaSemanticValidationVisitor.java in  » IDE-Netbeans » compapp » org » netbeans » modules » compapp » casaeditor » model » casa » validator » visitor » 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 » compapp » org.netbeans.modules.compapp.casaeditor.model.casa.validator.visitor 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003:         *
004:         * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005:         *
006:         * The contents of this file are subject to the terms of either the GNU
007:         * General Public License Version 2 only ("GPL") or the Common
008:         * Development and Distribution License("CDDL") (collectively, the
009:         * "License"). You may not use this file except in compliance with the
010:         * License. You can obtain a copy of the License at
011:         * http://www.netbeans.org/cddl-gplv2.html
012:         * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013:         * specific language governing permissions and limitations under the
014:         * License.  When distributing the software, include this License Header
015:         * Notice in each file and include the License file at
016:         * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
017:         * particular file as subject to the "Classpath" exception as provided
018:         * by Sun in the GPL Version 2 section of the License file that
019:         * accompanied this code. If applicable, add the following below the
020:         * License Header, with the fields enclosed by brackets [] replaced by
021:         * your own identifying information:
022:         * "Portions Copyrighted [year] [name of copyright owner]"
023:         *
024:         * Contributor(s):
025:         *
026:         * The Original Software is NetBeans. The Initial Developer of the Original
027:         * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
028:         * Microsystems, Inc. All Rights Reserved.
029:         *
030:         * If you wish your version of this file to be governed by only the CDDL
031:         * or only the GPL Version 2, indicate your decision by adding
032:         * "[Contributor] elects to include this software in this distribution
033:         * under the [CDDL or GPL Version 2] license." If you do not indicate a
034:         * single choice of license, a recipient has the option to distribute
035:         * your version of this file under either the CDDL, the GPL Version 2 or
036:         * to extend the choice of license to its licensees as provided above.
037:         * However, if you add GPL Version 2 code and therefore, elected the GPL
038:         * Version 2 license, then the option applies only if the new code is
039:         * made subject to such option by the copyright holder.
040:         */
041:        package org.netbeans.modules.compapp.casaeditor.model.casa.validator.visitor;
042:
043:        import java.util.HashSet;
044:        import java.util.List;
045:        import java.util.Set;
046:        import java.util.Vector;
047:        import javax.xml.namespace.QName;
048:        import org.netbeans.modules.compapp.casaeditor.model.casa.CasaComponentVisitor;
049:        import org.netbeans.modules.compapp.casaeditor.model.casa.CasaConnection;
050:        import org.netbeans.modules.compapp.casaeditor.model.casa.CasaConnections;
051:        import org.netbeans.modules.compapp.casaeditor.model.casa.CasaEndpoint;
052:        import org.netbeans.modules.compapp.casaeditor.model.casa.CasaEndpointRef;
053:        import org.netbeans.modules.compapp.casaeditor.model.casa.CasaLink;
054:        import org.netbeans.modules.compapp.casaeditor.model.casa.CasaServiceEngineServiceUnit;
055:        import org.netbeans.modules.compapp.casaeditor.model.casa.CasaWrapperModel;
056:        import org.netbeans.modules.compapp.casaeditor.model.casa.validator.CasaSemanticValidator;
057:        import org.netbeans.modules.xml.wsdl.model.Port;
058:        import org.netbeans.modules.xml.wsdl.model.PortType;
059:        import org.netbeans.modules.xml.xam.Model;
060:        import org.netbeans.modules.xml.xam.dom.NamedComponentReference;
061:        import org.netbeans.modules.xml.xam.spi.Validation;
062:        import org.netbeans.modules.xml.xam.spi.Validator;
063:        import org.netbeans.modules.xml.xam.spi.Validator.ResultItem;
064:        import org.openide.util.NbBundle;
065:
066:        /**
067:         *
068:         * @author jqian
069:         */
070:        public class CasaSemanticValidationVisitor extends
071:                CasaComponentVisitor.Deep {
072:
073:            private ValidateSupport mValidateSupport;
074:            public List<ResultItem> mResultItems;
075:            private Validation mValidation;
076:            private List<Model> mValidatedModels;
077:            private Validator mValidator;
078:            /** Validate configuration singleton. */
079:            private static ValidateConfiguration mValConfig;
080:
081:            public CasaSemanticValidationVisitor(
082:                    CasaSemanticValidator validator, Validation validation,
083:                    List<Model> validatedModels) {
084:
085:                synchronized (this .getClass()) {
086:                    mValConfig = new ValidateConfiguration();
087:                    mResultItems = new Vector<ResultItem>();
088:                }
089:
090:                mValidator = validator;
091:                mValidation = validation;
092:                mValidatedModels = validatedModels;
093:
094:                getValidateSupport().setValidator(mValidator);
095:                getValidateSupport().setResultItems(mResultItems);
096:            }
097:
098:            public List<ResultItem> getResultItems() {
099:                return mResultItems;
100:            }
101:
102:            // CSVR #1: Make sure no two connections share the same consumes endpoint.
103:            @Override
104:            public void visit(CasaConnections connections) {
105:                Set<String> consumerNames = new HashSet<String>();
106:
107:                for (CasaConnection connection : connections.getConnections()) {
108:                    String consumerName = connection.getConsumer()
109:                            .getRefString();
110:                    if (consumerNames.contains(consumerName)) {
111:                        CasaWrapperModel model = (CasaWrapperModel) connections
112:                                .getModel();
113:                        CasaEndpointRef consumes = model.getCasaEndpointRef(
114:                                connection, true);
115:
116:                        CasaEndpoint cEndpoint = connection.getConsumer().get();
117:                        QName consumeServiceQName = cEndpoint.getServiceQName();
118:                        String consumeEndpointName = cEndpoint
119:                                .getEndpointName();
120:
121:                        getValidateSupport()
122:                                .fireToDo(
123:                                        Validator.ResultType.ERROR,
124:                                        consumes,
125:                                        NbBundle
126:                                                .getMessage(
127:                                                        CasaSemanticValidationVisitor.class,
128:                                                        "ONE_CONSUMER_MULTIPLE_PROVIDERS", // NOI18N
129:                                                        /*consumeServiceQName + "." +*/consumeEndpointName),
130:                                        NbBundle
131:                                                .getMessage(
132:                                                        CasaSemanticValidationVisitor.class,
133:                                                        "FIX_ONE_CONSUMER_MULTIPLE_PROVIDERS")); // NOI18N
134:                    } else {
135:                        consumerNames.add(consumerName);
136:                    }
137:                }
138:            }
139:
140:            // CSVR #2: Make sure the two endpoints of a connection have the same interface.
141:            // CSVR #3: Make sure there is self connection.
142:            // CSVR #4: Make sure there is no connection connecting two external endpoints.
143:            @Override
144:            public void visit(CasaConnection connection) {
145:                CasaWrapperModel model = (CasaWrapperModel) connection
146:                        .getModel();
147:
148:                NamedComponentReference<CasaEndpoint> consumer = connection
149:                        .getConsumer();
150:                NamedComponentReference<CasaEndpoint> provider = connection
151:                        .getProvider();
152:
153:                if (consumer != null && provider != null) {
154:                    CasaEndpoint cEndpoint = consumer.get();
155:                    CasaEndpoint pEndpoint = provider.get();
156:
157:                    CasaEndpointRef consumes = model.getCasaEndpointRef(
158:                            connection, true);
159:                    CasaEndpointRef provides = model.getCasaEndpointRef(
160:                            connection, false);
161:
162:                    if (consumer.getRefString().equals(provider.getRefString())) {
163:                        getValidateSupport().fireToDo(
164:                                Validator.ResultType.ERROR,
165:                                consumes,
166:                                NbBundle.getMessage(
167:                                        CasaSemanticValidationVisitor.class,
168:                                        "SELF_CONNECTION"), // NOI18N
169:                                NbBundle.getMessage(
170:                                        CasaSemanticValidationVisitor.class,
171:                                        "FIX_SELF_CONNECTION")); // NOI18N
172:                    }
173:
174:                    QName cInterfaceQName = cEndpoint.getInterfaceQName();
175:                    QName pInterfaceQName = pEndpoint.getInterfaceQName();
176:                    if (!cInterfaceQName.equals(pInterfaceQName)) {
177:                        getValidateSupport()
178:                                .fireToDo(
179:                                        Validator.ResultType.ERROR,
180:                                        consumes,
181:                                        NbBundle
182:                                                .getMessage(
183:                                                        CasaSemanticValidationVisitor.class,
184:                                                        "ENDPOINTS_WITH_DIFFERENT_INTERFACES", // NOI18N
185:                                                        cInterfaceQName,
186:                                                        pInterfaceQName),
187:                                        NbBundle
188:                                                .getMessage(
189:                                                        CasaSemanticValidationVisitor.class,
190:                                                        "FIX_ENDPOINTS_WITH_DIFFERENT_INTERFACES")); // NOI18N
191:                    }
192:
193:                    CasaServiceEngineServiceUnit cSESU = model
194:                            .getCasaEngineServiceUnit(consumes);
195:                    CasaServiceEngineServiceUnit pSESU = model
196:                            .getCasaEngineServiceUnit(provides);
197:                    if (cSESU != null && pSESU != null && !cSESU.isInternal()
198:                            && !pSESU.isInternal()) {
199:                        getValidateSupport()
200:                                .fireToDo(
201:                                        Validator.ResultType.ERROR,
202:                                        consumes,
203:                                        NbBundle
204:                                                .getMessage(
205:                                                        CasaSemanticValidationVisitor.class,
206:                                                        "CONNECTING_TWO_EXTERNAL_ENDPOINTS", // NOI18N
207:                                                        cInterfaceQName,
208:                                                        pInterfaceQName),
209:                                        NbBundle
210:                                                .getMessage(
211:                                                        CasaSemanticValidationVisitor.class,
212:                                                        "FIX_CONNECTING_TWO_EXTERNAL_ENDPOINTS")); // NOI18N
213:                    }
214:                }
215:            }
216:
217:            // CSVR #6: Make sure SE SU's supporting WSDL is available.
218:            @Override
219:            public void visit(CasaServiceEngineServiceUnit sesu) {
220:                CasaWrapperModel model = (CasaWrapperModel) sesu.getModel();
221:
222:                for (CasaEndpointRef endpointRef : sesu.getEndpoints()) {
223:                    CasaEndpoint endpoint = endpointRef.getEndpoint().get();
224:                    QName interfaceQName = endpoint.getInterfaceQName();
225:                    PortType portType = model.getPortType(interfaceQName);
226:                    if (portType == null) {
227:                        getValidateSupport()
228:                                .fireToDo(
229:                                        Validator.ResultType.ERROR,
230:                                        sesu,
231:                                        NbBundle
232:                                                .getMessage(
233:                                                        CasaSemanticValidationVisitor.class,
234:                                                        "SERVICE_ENGINE_SERVICE_UNIT_WSDL_NOT_AVAILABLE", // NOI18N
235:                                                        endpoint
236:                                                                .getEndpointName()),
237:                                        NbBundle
238:                                                .getMessage(
239:                                                        CasaSemanticValidationVisitor.class,
240:                                                        "FIX_SERVICE_ENGINE_SERVICE_UNIT_WSDL_NOT_AVAILABLE")); // NOI18N
241:                    }
242:                }
243:            }
244:
245:            // CSVR #5: Make sure the linked WSDL component is available.
246:            @Override
247:            public void visit(CasaLink casaLink) {
248:                CasaWrapperModel model = (CasaWrapperModel) casaLink.getModel();
249:
250:                String linkHref = casaLink.getHref();
251:                try {
252:                    Port port = model.getWSDLComponentFromXLinkHref(linkHref,
253:                            Port.class);
254:
255:                    if (port == null) {
256:                        getValidateSupport().fireToDo(
257:                                Validator.ResultType.ERROR,
258:                                casaLink,
259:                                NbBundle.getMessage(
260:                                        CasaSemanticValidationVisitor.class,
261:                                        "WSDL_COMPONENT_NOT_AVAILABLE",
262:                                        linkHref), // NOI18N
263:                                NbBundle.getMessage(
264:                                        CasaSemanticValidationVisitor.class,
265:                                        "FIX_WSDL_COMPONENT_NOT_AVAILABLE")); // NOI18N
266:                    }
267:                } catch (Exception e) {
268:                    //???
269:                }
270:            }
271:
272:            /** Gets the validate visitor support.
273:             * @return  Visitor support.
274:             */
275:            public ValidateSupport getValidateSupport() {
276:                if (null == mValidateSupport) {
277:                    mValidateSupport = new ValidateSupport(mValConfig);
278:                }
279:                return mValidateSupport;
280:            }
281:
282:            public Validation getValidation() {
283:                return mValidation;
284:            }
285:
286:            public void setValidation(Validation validation) {
287:                this.mValidation = validation;
288:            }
289:
290:        }
w__ww_._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.