Replace wsdl4j by XAM-based model; support project reference when creating compapp test cases.
1.1 --- a/compapp.projects.jbi/src/org/netbeans/modules/compapp/test/ui/actions/AddTestcaseAction.java Thu May 24 15:07:09 2007 +0000
1.2 +++ b/compapp.projects.jbi/src/org/netbeans/modules/compapp/test/ui/actions/AddTestcaseAction.java Thu May 24 20:31:03 2007 +0000
1.3 @@ -16,12 +16,9 @@
1.4 * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
1.5 * Microsystems, Inc. All Rights Reserved.
1.6 */
1.7 -
1.8 -
1.9 package org.netbeans.modules.compapp.test.ui.actions;
1.10
1.11 import java.io.BufferedOutputStream;
1.12 -import java.io.ByteArrayInputStream;
1.13 import java.util.List;
1.14 import javax.wsdl.extensions.soap.SOAPOperation;
1.15 import org.netbeans.modules.compapp.projects.jbi.JbiProject;
1.16 @@ -35,14 +32,11 @@
1.17
1.18 import java.awt.Component;
1.19 import java.awt.Dialog;
1.20 -import java.io.BufferedWriter;
1.21 import java.io.FileOutputStream;
1.22 -import java.io.FileWriter;
1.23 import java.text.MessageFormat;
1.24 import java.util.HashMap;
1.25 import java.util.Map;
1.26 import org.openide.NotifyDescriptor;
1.27 -import org.openide.filesystems.FileLock;
1.28
1.29 import org.openide.nodes.Node;
1.30
1.31 @@ -51,11 +45,10 @@
1.32 import org.openide.util.actions.NodeAction;
1.33 import org.openide.filesystems.FileObject;
1.34 import java.util.logging.Level;
1.35 -import javax.swing.Action;
1.36 import javax.swing.JComponent;
1.37 import javax.swing.SwingUtilities;
1.38 -import javax.wsdl.BindingOperation;
1.39 import org.netbeans.api.project.Project;
1.40 +import org.netbeans.modules.xml.wsdl.model.BindingOperation;
1.41 import org.netbeans.spi.project.support.ant.EditableProperties;
1.42 import org.openide.DialogDisplayer;
1.43 import org.openide.WizardDescriptor;
1.44 @@ -63,15 +56,13 @@
1.45 import org.openide.explorer.view.TreeView;
1.46 import org.openide.filesystems.FileEvent;
1.47 import org.openide.filesystems.FileUtil;
1.48 -import org.openide.loaders.DataObject;
1.49 -import org.openide.util.RequestProcessor;
1.50 import org.openide.windows.TopComponent;
1.51 -import org.w3c.dom.Element;
1.52
1.53 /**
1.54 * DOCUMENT ME!
1.55 *
1.56 * @author Bing Lu
1.57 + * @author Jun Qian
1.58 */
1.59 public class AddTestcaseAction extends NodeAction implements NewTestcaseConstants {
1.60 private static final java.util.logging.Logger mLog =
1.61 @@ -129,12 +120,12 @@
1.62 final String name = (String) wizardDescriptor.getProperty(TESTCASE_NAME);
1.63 mLog.info("Got name in NewSchemaAction: " + name); // NOI18N
1.64 BindingSupport bindingSupport = (BindingSupport)wizardDescriptor.getProperty(BINDING_SUPPORT);
1.65 - BindingOperation operation = (BindingOperation)wizardDescriptor.getProperty(BINDING_OPERATION);
1.66 + BindingOperation bindingOp = (BindingOperation)wizardDescriptor.getProperty(BINDING_OPERATION);
1.67 Map param = new HashMap();
1.68 param.put(BindingSupport.BUILD_OPTIONAL, Boolean.TRUE);
1.69
1.70 try {
1.71 - String inputStr = bindingSupport.buildRequest(operation, param);
1.72 + String inputStr = bindingSupport.buildRequest(bindingOp, param);
1.73
1.74 FileObject testcaseDir = FileUtil.createFolder(testDir, name);
1.75 String fileName = FileUtil.toFile(testcaseDir).getPath() + "/Input.xml"; // NOI18N
1.76 @@ -170,7 +161,7 @@
1.77 }
1.78
1.79 String soapActionURI = ""; // NOI18N
1.80 - List list = operation.getExtensibilityElements();
1.81 + List list = bindingOp.getExtensibilityElements();
1.82 for (Object elem : list) {
1.83 if (elem instanceof SOAPOperation) {
1.84 SOAPOperation soapOperation = (SOAPOperation) elem;
2.1 --- a/compapp.projects.jbi/src/org/netbeans/modules/compapp/test/ui/wizards/NewTestcaseOperationVisualPanel.form Thu May 24 15:07:09 2007 +0000
2.2 +++ b/compapp.projects.jbi/src/org/netbeans/modules/compapp/test/ui/wizards/NewTestcaseOperationVisualPanel.form Thu May 24 20:31:03 2007 +0000
2.3 @@ -7,7 +7,9 @@
2.4 </Property>
2.5 </AccessibilityProperties>
2.6 <AuxValues>
2.7 + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
2.8 <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
2.9 + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
2.10 <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="2"/>
2.11 <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
2.12 <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
3.1 --- a/compapp.projects.jbi/src/org/netbeans/modules/compapp/test/ui/wizards/NewTestcaseOperationVisualPanel.java Thu May 24 15:07:09 2007 +0000
3.2 +++ b/compapp.projects.jbi/src/org/netbeans/modules/compapp/test/ui/wizards/NewTestcaseOperationVisualPanel.java Thu May 24 20:31:03 2007 +0000
3.3 @@ -2,16 +2,16 @@
3.4 * The contents of this file are subject to the terms of the Common Development
3.5 * and Distribution License (the License). You may not use this file except in
3.6 * compliance with the License.
3.7 - *
3.8 + *
3.9 * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
3.10 * or http://www.netbeans.org/cddl.txt.
3.11 - *
3.12 + *
3.13 * When distributing Covered Code, include this CDDL Header Notice in each file
3.14 * and include the License file at http://www.netbeans.org/cddl.txt.
3.15 * If applicable, add the following below the CDDL Header, with the fields
3.16 * enclosed by brackets [] replaced by your own identifying information:
3.17 * "Portions Copyrighted [year] [name of copyright owner]"
3.18 - *
3.19 + *
3.20 * The Original Software is NetBeans. The Initial Developer of the Original
3.21 * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
3.22 * Microsystems, Inc. All Rights Reserved.
3.23 @@ -20,7 +20,6 @@
3.24 package org.netbeans.modules.compapp.test.ui.wizards;
3.25
3.26 import org.netbeans.modules.compapp.test.wsdl.WsdlSupport;
3.27 -import java.util.List;
3.28 import javax.swing.JTree;
3.29 import javax.swing.event.TreeSelectionEvent;
3.30 import javax.swing.event.TreeSelectionListener;
3.31 @@ -28,17 +27,17 @@
3.32 import javax.swing.tree.DefaultTreeCellRenderer;
3.33 import javax.swing.tree.DefaultTreeModel;
3.34 import javax.swing.tree.TreeSelectionModel;
3.35 -import org.openide.WizardDescriptor;
3.36 import org.openide.util.NbBundle;
3.37 -import javax.wsdl.Binding;
3.38 -import javax.wsdl.BindingOperation;
3.39 -import org.netbeans.modules.compapp.test.wsdl.Util;
3.40 import java.awt.Component;
3.41 import javax.swing.JLabel;
3.42 import javax.swing.tree.TreePath;
3.43 -import javax.wsdl.Input;
3.44 -import javax.wsdl.Operation;
3.45 -import javax.wsdl.Output;
3.46 +import org.netbeans.modules.compapp.test.wsdl.Util;
3.47 +import org.netbeans.modules.xml.wsdl.model.Binding;
3.48 +import org.netbeans.modules.xml.wsdl.model.BindingOperation;
3.49 +import org.netbeans.modules.xml.wsdl.model.Input;
3.50 +import org.netbeans.modules.xml.wsdl.model.Operation;
3.51 +import org.netbeans.modules.xml.wsdl.model.Output;
3.52 +import org.netbeans.modules.xml.wsdl.model.WSDLModel;
3.53
3.54 public class NewTestcaseOperationVisualPanel extends javax.swing.JPanel {
3.55
3.56 @@ -53,15 +52,15 @@
3.57 mScrollPanel = new javax.swing.JScrollPane();
3.58 mTree = new javax.swing.JTree();
3.59 mTree.getAccessibleContext().setAccessibleName(
3.60 - NbBundle.getMessage(NewTestcaseWsdlVisualPanel.class, "ACS_OperationTree_A11YName")); // NOI18N
3.61 + NbBundle.getMessage(NewTestcaseWsdlVisualPanel.class, "ACS_OperationTree_A11YName")); // NOI18N
3.62 mTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
3.63 mTree.getSelectionModel().addTreeSelectionListener(new TreeSelectionListener() {
3.64 public void valueChanged(TreeSelectionEvent e) {
3.65 - Operation op = getSelectedOperation();
3.66 - if (op == null) {
3.67 + BindingOperation bindingOp = getSelectedBindingOperation();
3.68 + if (bindingOp == null) {
3.69 mOperationTf.setText(""); // NOI18N
3.70 } else {
3.71 - mOperationTf.setText(getOperationSignature(op));
3.72 + mOperationTf.setText(getOperationSignature(bindingOp));
3.73 }
3.74 mPanel.fireChangeEvent(); // Notify that the panel changed
3.75 }
3.76 @@ -70,41 +69,36 @@
3.77 mTree.setEditable(false);
3.78 mTree.setCellRenderer(new DefaultTreeCellRenderer() {
3.79 public Component getTreeCellRendererComponent(JTree tree,
3.80 - Object value,
3.81 - boolean sel,
3.82 - boolean expanded,
3.83 - boolean leaf,
3.84 - int row,
3.85 - boolean hasFocus)
3.86 - {
3.87 - JLabel lbl = (JLabel)super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);
3.88 - DefaultMutableTreeNode node = (DefaultMutableTreeNode)value;
3.89 + Object value,
3.90 + boolean sel,
3.91 + boolean expanded,
3.92 + boolean leaf,
3.93 + int row,
3.94 + boolean hasFocus) {
3.95 + JLabel label = (JLabel) super.getTreeCellRendererComponent(
3.96 + tree, value, sel, expanded, leaf, row, hasFocus);
3.97 + DefaultMutableTreeNode node = (DefaultMutableTreeNode) value;
3.98 Object usrObj = node.getUserObject();
3.99 if (usrObj instanceof Binding) {
3.100 - Binding bd = (Binding)usrObj;
3.101 - lbl.setText(bd.getQName().getLocalPart());
3.102 - return lbl;
3.103 + label.setText(((Binding)usrObj).getName());
3.104 + } else if (usrObj instanceof BindingOperation) {
3.105 + label.setText(((BindingOperation)usrObj).getName());
3.106 }
3.107 - if (usrObj instanceof Operation) {
3.108 - Operation op = (Operation)usrObj;
3.109 - lbl.setText(op.getName());
3.110 - return lbl;
3.111 - }
3.112 - return lbl;
3.113 - }
3.114 + return label;
3.115 + }
3.116 });
3.117
3.118 mScrollPanel.setViewportView(mTree);
3.119
3.120 org.jdesktop.layout.GroupLayout jPanel1Layout = (org.jdesktop.layout.GroupLayout) jPanel1.getLayout();
3.121 jPanel1Layout.setHorizontalGroup(
3.122 - jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
3.123 - .add(mScrollPanel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 400, Short.MAX_VALUE)
3.124 - );
3.125 + jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
3.126 + .add(mScrollPanel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 400, Short.MAX_VALUE)
3.127 + );
3.128 jPanel1Layout.setVerticalGroup(
3.129 - jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
3.130 - .add(mScrollPanel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 275, Short.MAX_VALUE)
3.131 - );
3.132 + jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
3.133 + .add(mScrollPanel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 275, Short.MAX_VALUE)
3.134 + );
3.135 }
3.136
3.137 public String getName() {
3.138 @@ -116,17 +110,15 @@
3.139 if (wsdlSupport == null) {
3.140 return;
3.141 }
3.142 + WSDLModel wsdlModel = wsdlSupport.getWsdlModel();
3.143 DefaultMutableTreeNode root = new DefaultMutableTreeNode();
3.144 - List bdList = Util.getSortedBindings(wsdlSupport.getDefinition());
3.145 - for (int i = 0; i < bdList.size(); i++) {
3.146 - DefaultMutableTreeNode bdNode = new DefaultMutableTreeNode(bdList.get(i));
3.147 - root.add(bdNode);
3.148 - List opList = Util.getSortedOperations((Binding)bdList.get(i));
3.149 - for (int j = 0; j < opList.size(); j++) {
3.150 - Operation op = (Operation)opList.get(j);
3.151 - DefaultMutableTreeNode opNode = new DefaultMutableTreeNode(op);
3.152 - bdNode.add(opNode);
3.153 - opNode.setAllowsChildren(false);
3.154 + for (Binding binding : Util.getSortedBindings(wsdlModel.getDefinitions())) {
3.155 + DefaultMutableTreeNode bindingNode = new DefaultMutableTreeNode(binding);
3.156 + root.add(bindingNode);
3.157 + for (BindingOperation bindingOp : Util.getSortedBindingOperations(binding)) {
3.158 + DefaultMutableTreeNode bindingOpNode = new DefaultMutableTreeNode(bindingOp);
3.159 + bindingNode.add(bindingOpNode);
3.160 + bindingOpNode.setAllowsChildren(false);
3.161 }
3.162 }
3.163 DefaultTreeModel dtm = new DefaultTreeModel(root);
3.164 @@ -143,7 +135,7 @@
3.165 return null;
3.166 }
3.167 DefaultMutableTreeNode node = (DefaultMutableTreeNode)value;
3.168 - if (node.getUserObject() instanceof Operation) {
3.169 + if (node.getUserObject() instanceof BindingOperation) {
3.170 DefaultMutableTreeNode parent = (DefaultMutableTreeNode)node.getParent();
3.171 return (Binding)parent.getUserObject();
3.172 }
3.173 @@ -151,22 +143,12 @@
3.174 }
3.175
3.176 public BindingOperation getSelectedBindingOperation() {
3.177 - Operation operation = getSelectedOperation();
3.178 - if (operation == null) {
3.179 - return null;
3.180 - }
3.181 - Binding binding = getSelectedBinding();
3.182 - return Util.getBindingOperation(binding, operation);
3.183 - }
3.184 -
3.185 - private Operation getSelectedOperation() {
3.186 Object value = mTree.getLastSelectedPathComponent();
3.187 - if (value == null) {
3.188 - return null;
3.189 - }
3.190 - DefaultMutableTreeNode node = (DefaultMutableTreeNode)value;
3.191 - if (node.getUserObject() instanceof Operation) {
3.192 - return (Operation)node.getUserObject();
3.193 + if (value != null) {
3.194 + Object userObj = ((DefaultMutableTreeNode) value).getUserObject();
3.195 + if (userObj instanceof BindingOperation) {
3.196 + return (BindingOperation) userObj;
3.197 + }
3.198 }
3.199 return null;
3.200 }
3.201 @@ -230,7 +212,10 @@
3.202 private javax.swing.JLabel mOperationLbl;
3.203 private javax.swing.JTextField mOperationTf;
3.204 // End of variables declaration//GEN-END:variables
3.205 - private static String getOperationSignature(Operation op) {
3.206 +
3.207 + private static String getOperationSignature(BindingOperation bindingOp) {
3.208 + Operation op = bindingOp.getOperation().get();
3.209 +
3.210 Input input = op.getInput();
3.211 Output output = op.getOutput();
3.212 StringBuffer sb = new StringBuffer();
3.213 @@ -245,5 +230,5 @@
3.214 sb.append("void"); // NOI18N
3.215 }
3.216 return sb.toString();
3.217 - }
3.218 + }
3.219 }
4.1 --- a/compapp.projects.jbi/src/org/netbeans/modules/compapp/test/ui/wizards/NewTestcaseOperationWizardPanel.java Thu May 24 15:07:09 2007 +0000
4.2 +++ b/compapp.projects.jbi/src/org/netbeans/modules/compapp/test/ui/wizards/NewTestcaseOperationWizardPanel.java Thu May 24 20:31:03 2007 +0000
4.3 @@ -29,7 +29,7 @@
4.4 import java.util.logging.Logger;
4.5 import javax.swing.event.ChangeEvent;
4.6 import javax.swing.event.ChangeListener;
4.7 -import javax.wsdl.Binding;
4.8 +import org.netbeans.modules.xml.wsdl.model.Binding;
4.9 import org.openide.WizardDescriptor;
4.10 import org.openide.WizardValidationException;
4.11 import org.openide.util.HelpCtx;
4.12 @@ -102,7 +102,7 @@
4.13 }
4.14 if (!isSupported) {
4.15 String msg = NbBundle.getMessage(NewTestcaseOperationWizardPanel.class,
4.16 - "LBL_Binding_is_not_supported", binding.getQName().toString()); // NOI18N
4.17 + "LBL_Binding_is_not_supported", binding.getName()); // NOI18N
4.18 wiz.putProperty("WizardPanel_errorMessage", msg); // NOI18N
4.19 return false;
4.20 }
4.21 @@ -156,8 +156,11 @@
4.22 for (int i = 0; i < mBindingSupportFactories.length; i++) {
4.23 if (mBindingSupportFactories[i].supports(binding)) {
4.24 try {
4.25 - bindingSupport = mBindingSupportFactories[i].createBindingSupport(binding,
4.26 - mWsdlSupport.getDefinition(), mWsdlSupport.getSchemaTypeLoader());
4.27 + bindingSupport =
4.28 + mBindingSupportFactories[i].createBindingSupport(
4.29 + binding,
4.30 + mWsdlSupport.getWsdlModel().getDefinitions(),
4.31 + mWsdlSupport.getSchemaTypeLoader());
4.32 break;
4.33 } catch (Exception e) {
4.34 }
5.1 --- a/compapp.projects.jbi/src/org/netbeans/modules/compapp/test/ui/wizards/NewTestcaseWsdlVisualPanel.form Thu May 24 15:07:09 2007 +0000
5.2 +++ b/compapp.projects.jbi/src/org/netbeans/modules/compapp/test/ui/wizards/NewTestcaseWsdlVisualPanel.form Thu May 24 20:31:03 2007 +0000
5.3 @@ -7,7 +7,9 @@
5.4 </Property>
5.5 </AccessibilityProperties>
5.6 <AuxValues>
5.7 + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
5.8 <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
5.9 + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
5.10 <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="2"/>
5.11 <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
5.12 <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
6.1 --- a/compapp.projects.jbi/src/org/netbeans/modules/compapp/test/ui/wizards/NewTestcaseWsdlVisualPanel.java Thu May 24 15:07:09 2007 +0000
6.2 +++ b/compapp.projects.jbi/src/org/netbeans/modules/compapp/test/ui/wizards/NewTestcaseWsdlVisualPanel.java Thu May 24 20:31:03 2007 +0000
6.3 @@ -21,15 +21,10 @@
6.4
6.5 import java.beans.PropertyChangeEvent;
6.6 import java.beans.PropertyChangeListener;
6.7 -import javax.swing.JPanel;
6.8 import javax.swing.JTree;
6.9 import javax.swing.event.TreeSelectionEvent;
6.10 import javax.swing.event.TreeSelectionListener;
6.11 -import javax.swing.tree.DefaultMutableTreeNode;
6.12 -import javax.swing.tree.TreeNode;
6.13 -import javax.swing.tree.TreePath;
6.14 import org.netbeans.api.project.Project;
6.15 -import org.openide.WizardDescriptor;
6.16 import org.openide.explorer.ExplorerManager;
6.17 import org.openide.filesystems.FileObject;
6.18 import org.openide.filesystems.FileUtil;
7.1 --- a/compapp.projects.jbi/src/org/netbeans/modules/compapp/test/ui/wizards/NewTestcaseWsdlWizardPanel.java Thu May 24 15:07:09 2007 +0000
7.2 +++ b/compapp.projects.jbi/src/org/netbeans/modules/compapp/test/ui/wizards/NewTestcaseWsdlWizardPanel.java Thu May 24 20:31:03 2007 +0000
7.3 @@ -31,12 +31,8 @@
7.4 import org.openide.WizardDescriptor;
7.5 import org.openide.WizardValidationException;
7.6 import org.openide.filesystems.FileObject;
7.7 -import org.openide.filesystems.FileUtil;
7.8 import org.openide.util.HelpCtx;
7.9 import org.openide.util.NbBundle;
7.10 -import javax.wsdl.Binding;
7.11 -import org.netbeans.modules.compapp.test.wsdl.Util;
7.12 -import java.util.List;
7.13 import org.openide.DialogDisplayer;
7.14 import org.openide.NotifyDescriptor;
7.15
7.16 @@ -139,7 +135,7 @@
7.17 mWsdlFile = wsdlFile;
7.18 WsdlSupport wsdlSupport = null;
7.19 if (wsdlFile != null) {
7.20 - wsdlSupport = new WsdlSupport("file:" + FileUtil.toFile(wsdlFile).getPath()); // NOI18N
7.21 + wsdlSupport = new WsdlSupport(wsdlFile); // NOI18N
7.22 }
7.23 mWsdlSupport = wsdlSupport;
7.24 wiz = (WizardDescriptor) settings;
7.25 @@ -177,11 +173,12 @@
7.26 }
7.27
7.28 try {
7.29 - // 2. Check for missing binding
7.30 - List bdList = Util.getSortedBindings(mWsdlSupport.getDefinition());
7.31 - for (int i = 0; i < bdList.size(); i++) {
7.32 - List opList = Util.getSortedOperations((Binding)bdList.get(i));
7.33 - }
7.34 + // TODO: fixme
7.35 +// // 2. Check for missing binding
7.36 +// List<Binding> bindings = Util.getSortedBindings(mWsdlSupport.getWsdlModel().getDefinitions());
7.37 +// for (Binding binding : bindings) {
7.38 +// List<Operation> opList = Util.getSortedOperations(binding);
7.39 +// }
7.40 } catch (Exception e) {
7.41 String msg = NbBundle.getMessage(NewTestcaseWsdlWizardPanel.class,
7.42 "LBL_No_Binding_Found"); // NOI18N
8.1 --- a/compapp.projects.jbi/src/org/netbeans/modules/compapp/test/ui/wizards/WsdlViewNodes.java Thu May 24 15:07:09 2007 +0000
8.2 +++ b/compapp.projects.jbi/src/org/netbeans/modules/compapp/test/ui/wizards/WsdlViewNodes.java Thu May 24 20:31:03 2007 +0000
8.3 @@ -16,17 +16,12 @@
8.4 * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
8.5 * Microsystems, Inc. All Rights Reserved.
8.6 */
8.7 -
8.8 -
8.9 package org.netbeans.modules.compapp.test.ui.wizards;
8.10
8.11 import java.awt.Image;
8.12 import java.beans.PropertyChangeEvent;
8.13 import java.beans.PropertyChangeListener;
8.14 -import java.io.FileNotFoundException;
8.15 -import java.io.IOException;
8.16 import java.io.InputStream;
8.17 -import java.net.URL;
8.18 import java.text.MessageFormat;
8.19 import java.util.ArrayList;
8.20 import java.util.Arrays;
8.21 @@ -38,10 +33,8 @@
8.22 import javax.swing.ImageIcon;
8.23 import javax.xml.parsers.DocumentBuilder;
8.24 import javax.xml.parsers.DocumentBuilderFactory;
8.25 -import javax.xml.parsers.ParserConfigurationException;
8.26 import javax.xml.xpath.XPath;
8.27 import javax.xml.xpath.XPathConstants;
8.28 -import javax.xml.xpath.XPathExpressionException;
8.29 import javax.xml.xpath.XPathFactory;
8.30 import org.netbeans.api.project.Project;
8.31 import org.netbeans.api.project.ProjectUtils;
8.32 @@ -63,7 +56,6 @@
8.33 import org.openide.util.NbBundle;
8.34 import org.w3c.dom.Document;
8.35 import org.w3c.dom.NodeList;
8.36 -import org.xml.sax.SAXException;
8.37
8.38 /**
8.39 * Support for creating logical views.
8.40 @@ -391,15 +383,7 @@
8.41 if (nodes.getLength() > 0) {
8.42 return true;
8.43 }
8.44 - } catch (FileNotFoundException ex) {
8.45 - ex.printStackTrace();
8.46 - } catch (IOException e) {
8.47 - e.printStackTrace();
8.48 - } catch (SAXException e) {
8.49 - e.printStackTrace();
8.50 - } catch (XPathExpressionException ex) {
8.51 - ex.printStackTrace();
8.52 - } catch (ParserConfigurationException ex) {
8.53 + } catch (Exception ex) {
8.54 ex.printStackTrace();
8.55 }
8.56 }
9.1 --- a/compapp.projects.jbi/src/org/netbeans/modules/compapp/test/wsdl/BindingSupport.java Thu May 24 15:07:09 2007 +0000
9.2 +++ b/compapp.projects.jbi/src/org/netbeans/modules/compapp/test/wsdl/BindingSupport.java Thu May 24 20:31:03 2007 +0000
9.3 @@ -16,12 +16,10 @@
9.4 * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
9.5 * Microsystems, Inc. All Rights Reserved.
9.6 */
9.7 -
9.8 -
9.9 package org.netbeans.modules.compapp.test.wsdl;
9.10
9.11 import java.util.Map;
9.12 -import javax.wsdl.BindingOperation;
9.13 +import org.netbeans.modules.xml.wsdl.model.BindingOperation;
9.14
9.15 /**
9.16 * BindingSupport.java
9.17 @@ -29,6 +27,7 @@
9.18 * Created on February 2, 2006, 3:17 PM
9.19 *
9.20 * @author Bing Lu
9.21 + * @author Jun Qian
9.22 */
9.23 public interface BindingSupport {
9.24 public static final String BUILD_OPTIONAL = "buildOptional"; // NOI18N
10.1 --- a/compapp.projects.jbi/src/org/netbeans/modules/compapp/test/wsdl/BindingSupportFactory.java Thu May 24 15:07:09 2007 +0000
10.2 +++ b/compapp.projects.jbi/src/org/netbeans/modules/compapp/test/wsdl/BindingSupportFactory.java Thu May 24 20:31:03 2007 +0000
10.3 @@ -2,16 +2,16 @@
10.4 * The contents of this file are subject to the terms of the Common Development
10.5 * and Distribution License (the License). You may not use this file except in
10.6 * compliance with the License.
10.7 - *
10.8 + *
10.9 * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
10.10 * or http://www.netbeans.org/cddl.txt.
10.11 - *
10.12 + *
10.13 * When distributing Covered Code, include this CDDL Header Notice in each file
10.14 * and include the License file at http://www.netbeans.org/cddl.txt.
10.15 * If applicable, add the following below the CDDL Header, with the fields
10.16 * enclosed by brackets [] replaced by your own identifying information:
10.17 * "Portions Copyrighted [year] [name of copyright owner]"
10.18 - *
10.19 + *
10.20 * The Original Software is NetBeans. The Initial Developer of the Original
10.21 * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
10.22 * Microsystems, Inc. All Rights Reserved.
10.23 @@ -20,8 +20,8 @@
10.24
10.25 package org.netbeans.modules.compapp.test.wsdl;
10.26
10.27 -import javax.wsdl.Binding;
10.28 -import javax.wsdl.Definition;
10.29 +import org.netbeans.modules.xml.wsdl.model.Binding;
10.30 +import org.netbeans.modules.xml.wsdl.model.Definitions;
10.31 import org.apache.xmlbeans.SchemaTypeLoader;
10.32
10.33 /**
10.34 @@ -30,10 +30,15 @@
10.35 * Created on February 2, 2006, 3:15 PM
10.36 *
10.37 * @author Bing Lu
10.38 + * @author Jun Qian
10.39 */
10.40 public interface BindingSupportFactory {
10.41 -
10.42 - public boolean supports(Binding binding);
10.43 -
10.44 - public BindingSupport createBindingSupport(Binding binding, Definition definition, SchemaTypeLoader schemaTypeLoader) throws Exception;
10.45 +
10.46 + public boolean supports(Binding binding);
10.47 +
10.48 + public BindingSupport createBindingSupport(
10.49 + Binding binding,
10.50 + Definitions definition,
10.51 + SchemaTypeLoader schemaTypeLoader)
10.52 + throws Exception;
10.53 }
11.1 --- a/compapp.projects.jbi/src/org/netbeans/modules/compapp/test/wsdl/SoapBindingOperationSupport.java Thu May 24 15:07:09 2007 +0000
11.2 +++ b/compapp.projects.jbi/src/org/netbeans/modules/compapp/test/wsdl/SoapBindingOperationSupport.java Thu May 24 20:31:03 2007 +0000
11.3 @@ -21,18 +21,24 @@
11.4 package org.netbeans.modules.compapp.test.wsdl;
11.5
11.6 import java.util.ArrayList;
11.7 -import java.util.Iterator;
11.8 +import java.util.Collection;
11.9 import java.util.List;
11.10 -import javax.wsdl.Binding;
11.11 -import javax.wsdl.BindingOperation;
11.12 -import javax.wsdl.Message;
11.13 -import javax.wsdl.OperationType;
11.14 -import javax.wsdl.Part;
11.15 -import javax.wsdl.extensions.soap.SOAPBinding;
11.16 -import javax.wsdl.extensions.soap.SOAPBody;
11.17 -import javax.wsdl.extensions.soap.SOAPOperation;
11.18 import java.util.logging.Logger;
11.19 -import javax.wsdl.BindingInput;
11.20 +import org.netbeans.modules.xml.wsdl.model.Binding;
11.21 +import org.netbeans.modules.xml.wsdl.model.BindingInput;
11.22 +import org.netbeans.modules.xml.wsdl.model.BindingOperation;
11.23 +import org.netbeans.modules.xml.wsdl.model.ExtensibilityElement;
11.24 +import org.netbeans.modules.xml.wsdl.model.Input;
11.25 +import org.netbeans.modules.xml.wsdl.model.Message;
11.26 +import org.netbeans.modules.xml.wsdl.model.Operation;
11.27 +import org.netbeans.modules.xml.wsdl.model.Output;
11.28 +import org.netbeans.modules.xml.wsdl.model.Part;
11.29 +import org.netbeans.modules.xml.wsdl.model.WSDLComponent;
11.30 +import org.netbeans.modules.xml.wsdl.model.extensions.soap.SOAPBinding;
11.31 +import org.netbeans.modules.xml.wsdl.model.extensions.soap.SOAPBinding.Style;
11.32 +import org.netbeans.modules.xml.wsdl.model.extensions.soap.SOAPBody;
11.33 +import org.netbeans.modules.xml.wsdl.model.extensions.soap.SOAPMessageBase.Use;
11.34 +import org.netbeans.modules.xml.wsdl.model.extensions.soap.SOAPOperation;
11.35 import org.openide.util.NbBundle;
11.36
11.37 /**
11.38 @@ -42,6 +48,7 @@
11.39 *
11.40 *
11.41 * @author Bing Lu
11.42 + * @author Jun Qian
11.43 */
11.44 public class SoapBindingOperationSupport {
11.45 private static final Logger mLog = Logger.getLogger("org.netbeans.modules.compapp.test.wsdl.SoapOperationSupport"); // NOI18N
11.46 @@ -52,25 +59,33 @@
11.47 /**
11.48 * Creates a new instance of SoapBindingOperationSupport
11.49 */
11.50 - public SoapBindingOperationSupport(Binding binding, BindingOperation bindingOperation) {
11.51 + public SoapBindingOperationSupport(Binding binding,
11.52 + BindingOperation bindingOperation) {
11.53 mBinding = binding;
11.54 mBindingOperation = bindingOperation;
11.55 }
11.56
11.57 public boolean isInputSoapEncoded() {
11.58 - OperationType operationType = mBindingOperation.getOperation().getStyle();
11.59 - if (operationType.equals(OperationType.NOTIFICATION)) {
11.60 - String msg = NbBundle.getMessage(SoapBindingOperationSupport.class,
11.61 - "MSG_No_Support_for_Notification_Style"); // NOI18N
11.62 - throw new RuntimeException(msg);
11.63 - } else if (operationType.equals(OperationType.SOLICIT_RESPONSE)) {
11.64 - String msg = NbBundle.getMessage(SoapBindingOperationSupport.class,
11.65 - "MSG_No_Support_for_Solicit_Response_Style"); // NOI18N
11.66 - throw new RuntimeException(msg);
11.67 - }
11.68 + Operation operation = mBindingOperation.getOperation().get();
11.69 + Input input = operation.getInput();
11.70 + Output output = operation.getOutput();
11.71 + if (output != null) {
11.72 + if (input == null) {
11.73 + String msg = NbBundle.getMessage(SoapBindingOperationSupport.class,
11.74 + "MSG_No_Support_for_Notification_Style"); // NOI18N
11.75 + throw new RuntimeException(msg);
11.76 + } else {
11.77 + List<WSDLComponent> children = operation.getChildren();
11.78 + if (children.get(0) instanceof Output) {
11.79 + String msg = NbBundle.getMessage(SoapBindingOperationSupport.class,
11.80 + "MSG_No_Support_for_Solicit_Response_Style"); // NOI18N
11.81 + throw new RuntimeException(msg);
11.82 + }
11.83 + }
11.84 + }
11.85
11.86 - BindingInput input = mBindingOperation.getBindingInput();
11.87 - if (input == null) {
11.88 + BindingInput bindingInput = mBindingOperation.getBindingInput();
11.89 + if (bindingInput == null) {
11.90 // If the wsdl file has been validated, this should not happen
11.91 // because the error should have already been caught above.
11.92 // Just to be safe...
11.93 @@ -79,13 +94,13 @@
11.94 throw new RuntimeException(msg);
11.95 }
11.96
11.97 - List list = input.getExtensibilityElements();
11.98 - SOAPBody body = (SOAPBody) Util.getAssignableExtensiblityElement(list, SOAPBody.class);
11.99 + List<ExtensibilityElement> eeList =
11.100 + bindingInput.getExtensibilityElements();
11.101 + SOAPBody soapBody =
11.102 + (SOAPBody) Util.getAssignableExtensiblityElement(eeList, SOAPBody.class);
11.103
11.104 - if (body != null &&
11.105 - body.getUse() != null &&
11.106 - body.getUse().equalsIgnoreCase("encoded")) { // NOI18N
11.107 - List encodingStyles = body.getEncodingStyles();
11.108 + if (soapBody != null && soapBody.getUse() == Use.ENCODED) {
11.109 + Collection<String> encodingStyles = soapBody.getEncodingStyles();
11.110 if (encodingStyles == null) {
11.111 String msg = NbBundle.getMessage(SoapBindingOperationSupport.class,
11.112 "MSG_Missing_EncodingStyle_for_Encoded_Use"); // NOI18N
11.113 @@ -99,35 +114,43 @@
11.114 }
11.115
11.116 public boolean isRpc() {
11.117 - List list = mBindingOperation.getExtensibilityElements();
11.118 - SOAPOperation soapOperation = (SOAPOperation) Util.getAssignableExtensiblityElement(list, SOAPOperation.class);
11.119 + List eeList = mBindingOperation.getExtensibilityElements();
11.120 + SOAPOperation soapOperation =
11.121 + (SOAPOperation) Util.getAssignableExtensiblityElement(
11.122 + eeList, SOAPOperation.class);
11.123
11.124 if(soapOperation != null && soapOperation.getStyle() != null) {
11.125 - return soapOperation.getStyle().equalsIgnoreCase("rpc"); // NOI18N
11.126 + return soapOperation.getStyle() == Style.RPC;
11.127 }
11.128 - list = mBinding.getExtensibilityElements();
11.129 - SOAPBinding soapBinding = (SOAPBinding) Util.getAssignableExtensiblityElement(list, SOAPBinding.class);
11.130 + eeList = mBinding.getExtensibilityElements();
11.131 + SOAPBinding soapBinding =
11.132 + (SOAPBinding) Util.getAssignableExtensiblityElement(
11.133 + eeList, SOAPBinding.class);
11.134
11.135 - return soapBinding != null &&
11.136 - soapBinding.getStyle() != null &&
11.137 - soapBinding.getStyle().equalsIgnoreCase("rpc"); // NOI18N
11.138 + return soapBinding != null && soapBinding.getStyle() == Style.RPC;
11.139 }
11.140
11.141 public Part[] getInputParts() {
11.142 ArrayList result = new ArrayList();
11.143 - Message msg = mBindingOperation.getOperation().getInput().getMessage();
11.144 - List list = mBindingOperation.getBindingInput().getExtensibilityElements();
11.145 - SOAPBody body = (SOAPBody) Util.getAssignableExtensiblityElement(list, SOAPBody.class);
11.146 + Operation operation = mBindingOperation.getOperation().get();
11.147 + Message msg = operation.getInput().getMessage().get();
11.148 + List<ExtensibilityElement> eeList =
11.149 + mBindingOperation.getBindingInput().getExtensibilityElements();
11.150 + SOAPBody body =
11.151 + (SOAPBody) Util.getAssignableExtensiblityElement(
11.152 + eeList, SOAPBody.class);
11.153
11.154 if (body == null || body.getParts() == null) {
11.155 - result.addAll(msg.getOrderedParts(null));
11.156 + result.addAll(msg.getParts());
11.157 } else {
11.158 - Iterator i = body.getParts().iterator();
11.159 - while (i.hasNext()) {
11.160 - String partName = (String) i.next();
11.161 - Part part = msg.getPart(partName);
11.162 -
11.163 - result.add(part);
11.164 + for (String partName : body.getParts()) {
11.165 +// Iterator i = body.getParts().iterator();
11.166 +// while (i.hasNext()) {
11.167 +// String partName = (String) i.next();
11.168 +// Part part = msg.getParts(partName);
11.169 +//
11.170 +// result.add(part);
11.171 + result.addAll(msg.getParts());
11.172 }
11.173 }
11.174
12.1 --- a/compapp.projects.jbi/src/org/netbeans/modules/compapp/test/wsdl/SoapBindingSupport.java Thu May 24 15:07:09 2007 +0000
12.2 +++ b/compapp.projects.jbi/src/org/netbeans/modules/compapp/test/wsdl/SoapBindingSupport.java Thu May 24 20:31:03 2007 +0000
12.3 @@ -2,16 +2,16 @@
12.4 * The contents of this file are subject to the terms of the Common Development
12.5 * and Distribution License (the License). You may not use this file except in
12.6 * compliance with the License.
12.7 - *
12.8 + *
12.9 * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
12.10 * or http://www.netbeans.org/cddl.txt.
12.11 - *
12.12 + *
12.13 * When distributing Covered Code, include this CDDL Header Notice in each file
12.14 * and include the License file at http://www.netbeans.org/cddl.txt.
12.15 * If applicable, add the following below the CDDL Header, with the fields
12.16 * enclosed by brackets [] replaced by your own identifying information:
12.17 * "Portions Copyrighted [year] [name of copyright owner]"
12.18 - *
12.19 + *
12.20 * The Original Software is NetBeans. The Initial Developer of the Original
12.21 * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
12.22 * Microsystems, Inc. All Rights Reserved.
12.23 @@ -20,18 +20,10 @@
12.24 package org.netbeans.modules.compapp.test.wsdl;
12.25
12.26 import java.util.ArrayList;
12.27 -import java.util.Iterator;
12.28 import java.util.List;
12.29 import java.util.Map;
12.30 import java.util.ResourceBundle;
12.31 import java.util.logging.Level;
12.32 -import javax.wsdl.Binding;
12.33 -import javax.wsdl.BindingOperation;
12.34 -import javax.wsdl.Definition;
12.35 -import javax.wsdl.Message;
12.36 -import javax.wsdl.Part;
12.37 -import javax.wsdl.extensions.soap.SOAPBody;
12.38 -import javax.wsdl.extensions.soap.SOAPHeader;
12.39 import javax.xml.namespace.QName;
12.40 import org.apache.xmlbeans.SchemaGlobalElement;
12.41 import org.apache.xmlbeans.SchemaType;
12.42 @@ -40,9 +32,17 @@
12.43 import org.apache.xmlbeans.XmlObject;
12.44 import org.openide.util.NbBundle;
12.45 import java.util.logging.Logger;
12.46 -import javax.wsdl.Port;
12.47 -import javax.wsdl.Service;
12.48 -import javax.wsdl.extensions.soap.SOAPAddress;
12.49 +import org.netbeans.modules.xml.wsdl.model.Binding;
12.50 +import org.netbeans.modules.xml.wsdl.model.BindingOperation;
12.51 +import org.netbeans.modules.xml.wsdl.model.Definitions;
12.52 +import org.netbeans.modules.xml.wsdl.model.ExtensibilityElement;
12.53 +import org.netbeans.modules.xml.wsdl.model.Message;
12.54 +import org.netbeans.modules.xml.wsdl.model.Part;
12.55 +import org.netbeans.modules.xml.wsdl.model.Port;
12.56 +import org.netbeans.modules.xml.wsdl.model.Service;
12.57 +import org.netbeans.modules.xml.wsdl.model.extensions.soap.SOAPAddress;
12.58 +import org.netbeans.modules.xml.wsdl.model.extensions.soap.SOAPBody;
12.59 +import org.netbeans.modules.xml.wsdl.model.extensions.soap.SOAPHeader;
12.60
12.61 /**
12.62 * SoapBindingSupport.java
12.63 @@ -50,6 +50,7 @@
12.64 * Created on February 2, 2006, 3:35 PM
12.65 *
12.66 * @author Bing Lu
12.67 + * @author Jun Qian
12.68 */
12.69 public class SoapBindingSupport implements BindingSupport {
12.70 private static final Logger mLog = Logger.getLogger("org.netbeans.modules.compapp.test.wsdl.SoapBindingSupport"); // NOI18N
12.71 @@ -64,35 +65,43 @@
12.72
12.73 private Binding mBinding;
12.74
12.75 - private Definition mDefinition;
12.76 + private Definitions mDefinition;
12.77
12.78 private SchemaTypeLoader mSchemaTypeLoader;
12.79
12.80 /** Creates a new instance of SoapBindingSupport */
12.81 - public SoapBindingSupport(Binding binding, Definition definition, SchemaTypeLoader schemaTypeLoader) {
12.82 + public SoapBindingSupport(
12.83 + Binding binding,
12.84 + Definitions definition,
12.85 + SchemaTypeLoader schemaTypeLoader) {
12.86 mBinding = binding;
12.87 mDefinition = definition;
12.88 mSchemaTypeLoader = schemaTypeLoader;
12.89 }
12.90
12.91 public String[] getEndpoints() {
12.92 - List result = new ArrayList();
12.93 - Map map = mDefinition.getServices();
12.94 - for(Iterator i = map.values().iterator(); i.hasNext(); ) {
12.95 - Service service = (Service) i.next();
12.96 - Map portMap = service.getPorts();
12.97 - for( Iterator i2 = portMap.values().iterator(); i2.hasNext(); ) {
12.98 - Port port = (Port) i2.next();
12.99 - if( port.getBinding() == mBinding) {
12.100 - SOAPAddress soapAddress = (SOAPAddress) Util.getAssignableExtensiblityElement(port.getExtensibilityElements(), SOAPAddress.class);
12.101 - result.add(soapAddress.getLocationURI());
12.102 + List<String> result = new ArrayList<String>();
12.103 +
12.104 + for (Service service : mDefinition.getServices()) {
12.105 + for (Port port : service.getPorts()) {
12.106 + if (port.getBinding().get() == mBinding) {
12.107 + List<ExtensibilityElement> eeList =
12.108 + port.getExtensibilityElements();
12.109 + SOAPAddress soapAddress = (SOAPAddress)
12.110 + Util.getAssignableExtensiblityElement(
12.111 + eeList, SOAPAddress.class);
12.112 + result.add(soapAddress.getLocation());
12.113 }
12.114 }
12.115 }
12.116 - return (String[])result.toArray( new String[0]);
12.117 + return (String[])result.toArray(new String[0]);
12.118 }
12.119
12.120 - public String buildRequest(BindingOperation bindingOperation, Map params) throws Exception {
12.121 + public String buildRequest(
12.122 + BindingOperation bindingOperation,
12.123 + Map params)
12.124 + throws Exception {
12.125 +
12.126 boolean buildOptional = false;
12.127 Object opt = params.get(BUILD_OPTIONAL);
12.128 if (opt == null) {
12.129 @@ -100,7 +109,8 @@
12.130 } else {
12.131 buildOptional = ((Boolean)opt).booleanValue();
12.132 }
12.133 - SoapBindingOperationSupport bindingOperationSupport = new SoapBindingOperationSupport(mBinding, bindingOperation);
12.134 + SoapBindingOperationSupport bindingOperationSupport =
12.135 + new SoapBindingOperationSupport(mBinding, bindingOperation);
12.136 boolean inputSoapEncoded = bindingOperationSupport.isInputSoapEncoded();
12.137 SampleXmlUtil xmlGenerator = new SampleXmlUtil(inputSoapEncoded);
12.138 xmlGenerator.setIgnoreOptional(!buildOptional);
12.139 @@ -110,12 +120,14 @@
12.140 cursor.toNextToken();
12.141 cursor.beginElement(mEnvelopeQName);
12.142
12.143 -// if(inputSoapEncoded) {
12.144 - cursor.insertNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance"); // NOI18N
12.145 - cursor.insertNamespace("xsd", "http://www.w3.org/2001/XMLSchema"); // NOI18N
12.146 -// }
12.147 - cursor.insertAttributeWithValue("schemaLocation", "http://www.w3.org/2001/XMLSchema-instance", "http://schemas.xmlsoap.org/soap/envelope/ http://schemas.xmlsoap.org/soap/envelope/"); // NOI18N
12.148 -
12.149 +// if(inputSoapEncoded) {
12.150 + cursor.insertNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance"); // NOI18N
12.151 + cursor.insertNamespace("xsd", "http://www.w3.org/2001/XMLSchema"); // NOI18N
12.152 +// }
12.153 + cursor.insertAttributeWithValue("schemaLocation", // NOI18N
12.154 + "http://www.w3.org/2001/XMLSchema-instance", // NOI18N
12.155 + "http://schemas.xmlsoap.org/soap/envelope/ http://schemas.xmlsoap.org/soap/envelope/"); // NOI18N
12.156 +
12.157 cursor.toFirstChild();
12.158
12.159 cursor.beginElement(mBodyQName);
12.160 @@ -137,9 +149,16 @@
12.161 }
12.162 }
12.163
12.164 - private void addHeaders(BindingOperation bindingOperation, XmlCursor cursor, SampleXmlUtil xmlGenerator) throws Exception {
12.165 - List list = bindingOperation.getBindingInput().getExtensibilityElements();
12.166 - List headers = Util.getAssignableExtensiblityElementList(list, SOAPHeader.class);
12.167 + private void addHeaders(
12.168 + BindingOperation bindingOperation,
12.169 + XmlCursor cursor,
12.170 + SampleXmlUtil xmlGenerator)
12.171 + throws Exception {
12.172 +
12.173 + List<ExtensibilityElement> eeList =
12.174 + bindingOperation.getBindingInput().getExtensibilityElements();
12.175 + List headers =
12.176 + Util.getAssignableExtensiblityElementList(eeList, SOAPHeader.class);
12.177 if (headers.isEmpty()) {
12.178 return;
12.179 }
12.180 @@ -153,22 +172,36 @@
12.181
12.182 for (int i = 0, I = headers.size(); i < I; i++) {
12.183 SOAPHeader header = (SOAPHeader) headers.get(i);
12.184 - QName messageName = header.getMessage();
12.185 + String messageName = header.getMessage().get().getName();
12.186 String partName = header.getPart();
12.187 - Message message = mDefinition.getMessage(messageName);
12.188 - Part part = message.getPart(partName);
12.189
12.190 - if(part != null) {
12.191 - createElementForPart(part, cursor, xmlGenerator);
12.192 - } else {
12.193 - mLog.log(Level.SEVERE,
12.194 - NbBundle.getMessage(SoapBindingSupport.class, "LBL_Header_has_missing_part", partName)); // NOI18N
12.195 + for (Message message : mDefinition.getMessages()) {
12.196 + if (message.getName().equals(messageName)) {
12.197 + for (Part part : message.getParts()) {
12.198 + if (part.getName().equals(partName)) {
12.199 + if(part != null) {
12.200 + createElementForPart(part, cursor, xmlGenerator);
12.201 + } else {
12.202 + mLog.log(Level.SEVERE,
12.203 + NbBundle.getMessage(SoapBindingSupport.class,
12.204 + "LBL_Header_has_missing_part", partName)); // NOI18N
12.205 + }
12.206 + break;
12.207 + }
12.208 + }
12.209 + break;
12.210 + }
12.211 }
12.212 }
12.213 }
12.214
12.215 - private void createElementForPart(Part part, XmlCursor cursor, SampleXmlUtil xmlGenerator) throws Exception {
12.216 - QName elementName = part.getElementName();
12.217 + private void createElementForPart(
12.218 + Part part,
12.219 + XmlCursor cursor,
12.220 + SampleXmlUtil xmlGenerator)
12.221 + throws Exception {
12.222 +
12.223 + QName elementName = part.getElement().getQName();
12.224 if(elementName != null) {
12.225 cursor.beginElement(elementName);
12.226 SchemaGlobalElement elm = mSchemaTypeLoader.findElement(elementName);
12.227 @@ -178,7 +211,7 @@
12.228 }
12.229 cursor.toParent();
12.230 } else {
12.231 - QName typeName = part.getTypeName();
12.232 + QName typeName = part.getType().getQName();
12.233 cursor.beginElement(new QName(mDefinition.getTargetNamespace(), part.getName()));
12.234 SchemaType type = mSchemaTypeLoader.findType(typeName);
12.235 if(type != null) {
12.236 @@ -189,9 +222,12 @@
12.237 }
12.238 }
12.239
12.240 - private void buildDocumentRequest(SoapBindingOperationSupport bindingOperationSupport,
12.241 + private void buildDocumentRequest(
12.242 + SoapBindingOperationSupport bindingOperationSupport,
12.243 XmlCursor cursor,
12.244 - SampleXmlUtil xmlGenerator) throws Exception {
12.245 + SampleXmlUtil xmlGenerator)
12.246 + throws Exception {
12.247 +
12.248 Part[] parts = bindingOperationSupport.getInputParts();
12.249 if(parts.length > 1)
12.250 mLog.log(Level.SEVERE,
12.251 @@ -206,25 +242,30 @@
12.252 }
12.253 }
12.254
12.255 - private void buildRpcRequest(SoapBindingOperationSupport bindingOperationSupport,
12.256 + private void buildRpcRequest(
12.257 + SoapBindingOperationSupport bindingOperationSupport,
12.258 XmlCursor cursor,
12.259 - SampleXmlUtil xmlGenerator) throws Exception {
12.260 + SampleXmlUtil xmlGenerator)
12.261 + throws Exception {
12.262 +
12.263 // rpc requests use the bindingOperation name as root element
12.264 BindingOperation bindingOperation = bindingOperationSupport.getBindingOperation();
12.265 List list = bindingOperation.getBindingInput().getExtensibilityElements();
12.266 SOAPBody body = (SOAPBody) Util.getAssignableExtensiblityElement(list, SOAPBody.class);
12.267
12.268 String ns = mDefinition.getTargetNamespace();
12.269 - if(body != null && body.getNamespaceURI() != null) {
12.270 - ns = body.getNamespaceURI();
12.271 + if(body != null && body.getNamespace() != null) {
12.272 + ns = body.getNamespace();
12.273 }
12.274 cursor.beginElement(new QName(ns, bindingOperation.getName()));
12.275 - if(xmlGenerator.isSoapEnc())
12.276 - cursor.insertAttributeWithValue(new QName("http://schemas.xmlsoap.org/soap/envelope/", // NOI18N
12.277 + if(xmlGenerator.isSoapEnc()) {
12.278 + cursor.insertAttributeWithValue(
12.279 + new QName("http://schemas.xmlsoap.org/soap/envelope/", // NOI18N
12.280 "encodingStyle"), // NOI18N
12.281 "http://schemas.xmlsoap.org/soap/encoding/"); // NOI18N
12.282 + }
12.283
12.284 - Part[] inputParts = bindingOperationSupport.getInputParts();
12.285 + Part[] inputParts = bindingOperationSupport.getInputParts();
12.286 for (int i = 0; i < inputParts.length; i++) {
12.287 Part part = inputParts[i];
12.288 XmlCursor c = cursor.newCursor();
12.289 @@ -232,14 +273,17 @@
12.290 c.insertElement(part.getName());
12.291 c.toPrevToken();
12.292
12.293 - SchemaType type = mSchemaTypeLoader.findType(part.getTypeName());
12.294 - if(type != null) {
12.295 + if (part.getType() != null && part.getType().getQName() != null) {
12.296 + SchemaType type = mSchemaTypeLoader.findType(part.getType().getQName());
12.297 xmlGenerator.createSampleForType(type, c);
12.298 + } else if (part.getElement() != null) {
12.299 + SchemaGlobalElement element = mSchemaTypeLoader.findElement(part.getElement().getQName());
12.300 + xmlGenerator.createSampleForType(element.getType(), c);
12.301 } else {
12.302 mLog.log(Level.SEVERE,
12.303 NbBundle.getMessage(SoapBindingSupport.class,
12.304 "LBL_Type_cannot_be_found", // NOI18N
12.305 - part.getTypeName()));
12.306 + part.getType().getQName()));
12.307 }
12.308 c.dispose();
12.309 }
13.1 --- a/compapp.projects.jbi/src/org/netbeans/modules/compapp/test/wsdl/SoapBindingSupportFactory.java Thu May 24 15:07:09 2007 +0000
13.2 +++ b/compapp.projects.jbi/src/org/netbeans/modules/compapp/test/wsdl/SoapBindingSupportFactory.java Thu May 24 20:31:03 2007 +0000
13.3 @@ -21,11 +21,11 @@
13.4 package org.netbeans.modules.compapp.test.wsdl;
13.5
13.6 import java.util.List;
13.7 -import javax.wsdl.Binding;
13.8 -import javax.wsdl.Definition;
13.9 -import javax.wsdl.extensions.soap.SOAPBinding;
13.10 import org.apache.xmlbeans.SchemaTypeLoader;
13.11 import java.util.logging.Logger;
13.12 +import org.netbeans.modules.xml.wsdl.model.Binding;
13.13 +import org.netbeans.modules.xml.wsdl.model.Definitions;
13.14 +import org.netbeans.modules.xml.wsdl.model.extensions.soap.SOAPBinding;
13.15
13.16 /**
13.17 * SoapBindingSupportFactory.java
13.18 @@ -37,18 +37,26 @@
13.19 public class SoapBindingSupportFactory implements BindingSupportFactory {
13.20 private static final Logger mLog = Logger.getLogger("org.netbeans.modules.compapp.test.wsdl.SoapBindingSupportFactory"); // NOI18N
13.21
13.22 + private static final String SOAP_TRANSPORT_URI =
13.23 + "http://schemas.xmlsoap.org/soap/http"; // NOI18N
13.24 +
13.25 /** Creates a new instance of SoapBindingSupportFactory */
13.26 public SoapBindingSupportFactory() {
13.27 }
13.28
13.29 public boolean supports(Binding binding) {
13.30 - List list = binding.getExtensibilityElements();
13.31 - SOAPBinding soapBinding = (SOAPBinding) Util.getAssignableExtensiblityElement(list, SOAPBinding.class);
13.32 + List eeList = binding.getExtensibilityElements();
13.33 + SOAPBinding soapBinding = (SOAPBinding)
13.34 + Util.getAssignableExtensiblityElement(eeList, SOAPBinding.class);
13.35 return soapBinding == null ? false :
13.36 - soapBinding.getTransportURI().startsWith( "http://schemas.xmlsoap.org/soap/http"); // NOI18N
13.37 + soapBinding.getTransportURI().startsWith(SOAP_TRANSPORT_URI);
13.38 }
13.39
13.40 - public BindingSupport createBindingSupport(Binding binding, Definition definition, SchemaTypeLoader schemaTypeLoader) throws Exception {
13.41 + public BindingSupport createBindingSupport(
13.42 + Binding binding,
13.43 + Definitions definition,
13.44 + SchemaTypeLoader schemaTypeLoader)
13.45 + throws Exception {
13.46 return new SoapBindingSupport(binding, definition, schemaTypeLoader);
13.47 }
13.48 }
14.1 --- a/compapp.projects.jbi/src/org/netbeans/modules/compapp/test/wsdl/Util.java Thu May 24 15:07:09 2007 +0000
14.2 +++ b/compapp.projects.jbi/src/org/netbeans/modules/compapp/test/wsdl/Util.java Thu May 24 20:31:03 2007 +0000
14.3 @@ -16,29 +16,20 @@
14.4 * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
14.5 * Microsystems, Inc. All Rights Reserved.
14.6 */
14.7 -
14.8 -
14.9 package org.netbeans.modules.compapp.test.wsdl;
14.10
14.11 import java.io.StringWriter;
14.12 import java.util.ArrayList;
14.13 import java.util.Collections;
14.14 import java.util.Comparator;
14.15 -import java.util.Iterator;
14.16 import java.util.List;
14.17 -import java.util.Map;
14.18 -import javax.wsdl.extensions.ExtensibilityElement;
14.19 import org.apache.xmlbeans.XmlObject;
14.20 import org.apache.xmlbeans.XmlOptions;
14.21 import java.util.logging.Logger;
14.22 -import javax.wsdl.Binding;
14.23 -import javax.wsdl.BindingOperation;
14.24 -import javax.wsdl.Definition;
14.25 -import javax.wsdl.Input;
14.26 -import javax.wsdl.Operation;
14.27 -import javax.wsdl.Output;
14.28 -import javax.wsdl.PortType;
14.29 -import javax.xml.namespace.QName;
14.30 +import org.netbeans.modules.xml.wsdl.model.Binding;
14.31 +import org.netbeans.modules.xml.wsdl.model.BindingOperation;
14.32 +import org.netbeans.modules.xml.wsdl.model.Definitions;
14.33 +import org.netbeans.modules.xml.wsdl.model.ExtensibilityElement;
14.34
14.35 /**
14.36 * Util.java
14.37 @@ -46,20 +37,23 @@
14.38 * Created on February 2, 2006, 3:27 PM
14.39 *
14.40 * @author Bing Lu
14.41 + * @author Jun Qian
14.42 */
14.43 public class Util {
14.44 private static final Logger mLog = Logger.getLogger("org.netbeans.modules.compapp.test.wsdl.Util"); // NOI18N
14.45
14.46 - public static ExtensibilityElement getAssignableExtensiblityElement(List list, Class type) {
14.47 - List eelist = getAssignableExtensiblityElementList(list, type);
14.48 - return eelist.size() > 0? (ExtensibilityElement)eelist.get(0) : null;
14.49 + public static ExtensibilityElement getAssignableExtensiblityElement(
14.50 + List<ExtensibilityElement> list, Class type) {
14.51 + List<ExtensibilityElement> eelist =
14.52 + getAssignableExtensiblityElementList(list, type);
14.53 + return eelist.size() > 0? eelist.get(0) : null;
14.54 }
14.55
14.56 - public static List getAssignableExtensiblityElementList(List list, Class type) {
14.57 - List result = new ArrayList();
14.58 + public static List<ExtensibilityElement> getAssignableExtensiblityElementList(
14.59 + List<ExtensibilityElement> list, Class type) {
14.60 + List<ExtensibilityElement> result = new ArrayList<ExtensibilityElement>();
14.61
14.62 - for (int i = 0, I = list.size(); i < I; i++) {
14.63 - ExtensibilityElement ee = (ExtensibilityElement) list.get(i);
14.64 + for (ExtensibilityElement ee : list) {
14.65 if(type.isAssignableFrom(ee.getClass())) {
14.66 result.add(ee);
14.67 }
14.68 @@ -79,31 +73,27 @@
14.69 return writer.toString();
14.70 }
14.71
14.72 - public static List getSortedBindings(Definition def) {
14.73 - List bdNameList = new ArrayList();
14.74 - Map bdMap = def.getBindings();
14.75 - for (Iterator itr = bdMap.keySet().iterator(); itr.hasNext();) {
14.76 - QName qn = (QName)itr.next();
14.77 - bdNameList.add(qn);
14.78 - }
14.79 - Collections.sort(bdNameList, new Comparator() {
14.80 + public static List<Binding> getSortedBindings(Definitions definitions) {
14.81 + List<Binding> bindings =
14.82 + new ArrayList<Binding>(definitions.getBindings());
14.83 +
14.84 + Collections.sort(bindings, new Comparator() {
14.85 public int compare(Object o1, Object o2) {
14.86 - return ((QName)o1).getLocalPart().compareTo(((QName)o2).getLocalPart());
14.87 + return ((Binding)o1).getName().compareTo(((Binding)o2).getName());
14.88 }
14.89 public boolean equals(Object obj) {
14.90 return this == obj;
14.91 }
14.92 });
14.93 - List bdList = new ArrayList();
14.94 - for (int i = 0; i < bdNameList.size(); i++) {
14.95 - bdList.add(bdMap.get(bdNameList.get(i)));
14.96 - }
14.97 - return bdList;
14.98 - }
14.99 +
14.100 + return bindings;
14.101 + }
14.102
14.103 - public static List getSortedBindingOperations(Binding binding) {
14.104 - List opList = binding.getBindingOperations();
14.105 - Collections.sort(opList, new Comparator() {
14.106 + public static List<BindingOperation> getSortedBindingOperations(Binding binding) {
14.107 + List<BindingOperation> bindingOps =
14.108 + new ArrayList<BindingOperation>(binding.getBindingOperations());
14.109 +
14.110 + Collections.sort(bindingOps, new Comparator() {
14.111 public int compare(Object o1, Object o2) {
14.112 return ((BindingOperation)o1).getName().compareTo(((BindingOperation)o2).getName());
14.113 }
14.114 @@ -111,58 +101,7 @@
14.115 return this == obj;
14.116 }
14.117 });
14.118 - return opList;
14.119 - }
14.120 -
14.121 - public static List getSortedOperations(Binding binding) {
14.122 - PortType portType = binding.getPortType();
14.123 - List opList = portType.getOperations();
14.124 - Collections.sort(opList, new Comparator() {
14.125 - public int compare(Object o1, Object o2) {
14.126 - Operation op1 = (Operation)o1;
14.127 - Operation op2 = (Operation)o2;
14.128 -
14.129 - int i0 = 100*op1.getName().compareTo(op2.getName());
14.130 -
14.131 - String in1 = op1.getInput() == null? " " : op1.getInput().getMessage().getQName().getLocalPart(); // NOI18N
14.132 - String in2 = op2.getInput() == null? " " : op2.getInput().getMessage().getQName().getLocalPart(); // NOI18N
14.133 - int i1 = 10*in1.compareTo(in2);
14.134 -
14.135 - String out1 = op1.getOutput() == null? " " : op1.getOutput().getMessage().getQName().getLocalPart(); // NOI18N
14.136 - String out2 = op2.getOutput() == null? " " : op2.getOutput().getMessage().getQName().getLocalPart(); // NOI18N
14.137 - int i2 = out1.compareTo(out2);
14.138 -
14.139 - return i0 + i1 + i2;
14.140 - }
14.141 - public boolean equals(Object obj) {
14.142 - return this == obj;
14.143 - }
14.144 - });
14.145 - return opList;
14.146 - }
14.147 -
14.148 - public static BindingOperation getBindingOperation(Binding binding, Operation operation) {
14.149 - List bopList = binding.getBindingOperations();
14.150 - List nameMatchList = new ArrayList();
14.151 - for (int i = 0; i < bopList.size(); i++) {
14.152 - BindingOperation bop = (BindingOperation)bopList.get(i);
14.153 - if (bop.getName().equals(operation.getName())) {
14.154 - nameMatchList.add(bop);
14.155 - }
14.156 - }
14.157 - if (nameMatchList.size() == 0) {
14.158 - return null;
14.159 - }
14.160 - if (nameMatchList.size() == 1) {
14.161 - return (BindingOperation)nameMatchList.get(0);
14.162 - }
14.163 - // Overloaded operations: BindingOperation must specifiy their input names
14.164 - // and output names, hence can be searched using operation's input name and
14.165 - // output name
14.166 - Input input = operation.getInput();
14.167 - String inputName = input == null? null : input.getName();
14.168 - Output output = operation.getOutput();
14.169 - String outputName = output == null? null : output.getName();
14.170 - return binding.getBindingOperation(operation.getName(), inputName, outputName);
14.171 - }
14.172 +
14.173 + return bindingOps;
14.174 + }
14.175 }
15.1 --- a/compapp.projects.jbi/src/org/netbeans/modules/compapp/test/wsdl/WsdlSupport.java Thu May 24 15:07:09 2007 +0000
15.2 +++ b/compapp.projects.jbi/src/org/netbeans/modules/compapp/test/wsdl/WsdlSupport.java Thu May 24 20:31:03 2007 +0000
15.3 @@ -22,16 +22,14 @@
15.4
15.5 import java.io.File;
15.6 import java.io.IOException;
15.7 +import java.net.URI;
15.8 import java.net.URL;
15.9 import java.util.ArrayList;
15.10 +import java.util.Arrays;
15.11 import java.util.HashMap;
15.12 import java.util.List;
15.13 import java.util.Map;
15.14 import java.util.logging.Level;
15.15 -import javax.wsdl.Definition;
15.16 -import javax.wsdl.factory.WSDLFactory;
15.17 -import javax.wsdl.xml.WSDLReader;
15.18 -import javax.wsdl.WSDLException;
15.19 import org.apache.xmlbeans.XmlException;
15.20 import javax.xml.namespace.QName;
15.21 import org.apache.xmlbeans.SchemaTypeLoader;
15.22 @@ -41,12 +39,18 @@
15.23 import org.apache.xmlbeans.XmlException;
15.24 import org.apache.xmlbeans.XmlObject;
15.25 import org.apache.xmlbeans.XmlOptions;
15.26 -import org.openide.DialogDisplayer;
15.27 -import org.openide.NotifyDescriptor;
15.28 import org.openide.util.NbBundle;
15.29 import org.w3c.dom.Document;
15.30 import org.w3c.dom.Node;
15.31 import java.util.logging.Logger;
15.32 +import org.netbeans.modules.xml.retriever.catalog.CatalogWriteModel;
15.33 +import org.netbeans.modules.xml.retriever.catalog.CatalogWriteModelFactory;
15.34 +import org.netbeans.modules.xml.retriever.catalog.Utilities;
15.35 +import org.netbeans.modules.xml.wsdl.model.WSDLModel;
15.36 +import org.netbeans.modules.xml.wsdl.model.WSDLModelFactory;
15.37 +import org.netbeans.modules.xml.xam.ModelSource;
15.38 +import org.openide.filesystems.FileObject;
15.39 +import org.openide.filesystems.FileUtil;
15.40
15.41 /**
15.42 * WsdlSupport.java
15.43 @@ -57,40 +61,22 @@
15.44 public class WsdlSupport {
15.45 private static final Logger mLog =Logger.getLogger("org.netbeans.modules.compapp.test.wsdl.WsdlSupport"); // NOI18N
15.46
15.47 - private String mUrl;
15.48 - private Definition mDefinition;
15.49 + private String mWsdlUrl;
15.50 + private WSDLModel mWsdlModel;
15.51 private SchemaTypeLoader mSchemaTypeLoader;
15.52 private String wsdlSupportErrStr = ""; //NOI18N
15.53
15.54 /** Creates a new instance of WsdlSupport */
15.55 - public WsdlSupport(String url) {
15.56 - mUrl = url;
15.57 + public WsdlSupport(FileObject wsdlFile) {
15.58 + mWsdlUrl = "file:" + FileUtil.toFile(wsdlFile).getPath();
15.59
15.60 try {
15.61 - WSDLFactory factory = WSDLFactory.newInstance();
15.62 - WSDLReader wsdlReader = factory.newWSDLReader();
15.63 - wsdlReader.setFeature("javax.wsdl.verbose", true); // NOI18N
15.64 - wsdlReader.setFeature("javax.wsdl.importDocuments", true); // NOI18N
15.65 -
15.66 - mDefinition = wsdlReader.readWSDL(url);
15.67 -
15.68 - } catch (WSDLException e) {
15.69 - String msg = NbBundle.getMessage(WsdlSupport.class, "LBL_Fail_to_load_wsdl", url); // NOI18N
15.70 - if (e.getMessage() != null) {
15.71 - msg += "\n" + e.getMessage(); // NOI18N
15.72 - }
15.73 - wsdlSupportErrStr += msg;
15.74 - mLog.log(Level.SEVERE, msg, e); // NOI18N
15.75 -
15.76 -// NotifyDescriptor d =
15.77 -// new NotifyDescriptor.Message(msg, NotifyDescriptor.ERROR_MESSAGE);
15.78 -// DialogDisplayer.getDefault().notify(d);
15.79 - }
15.80 + ModelSource wsdlModelSource = Utilities.createModelSource(wsdlFile, false);
15.81 + mWsdlModel = WSDLModelFactory.getDefault().getModel(wsdlModelSource);
15.82
15.83 - try {
15.84 - mSchemaTypeLoader = loadSchemaTypes(url);
15.85 + mSchemaTypeLoader = loadSchemaTypes(mWsdlUrl);
15.86 } catch (Exception e) {
15.87 - String msg = NbBundle.getMessage(WsdlSupport.class, "LBL_Fail_to_load_schema_types", url); // NOI18N
15.88 + String msg = NbBundle.getMessage(WsdlSupport.class, "LBL_Fail_to_load_schema_types", mWsdlUrl); // NOI18N
15.89 if (e.getMessage() != null) {
15.90 msg += "\n" + e.getMessage(); // NOI18N
15.91 }
15.92 @@ -103,10 +89,10 @@
15.93 }
15.94 }
15.95
15.96 - public Definition getDefinition() {
15.97 - return mDefinition;
15.98 + public WSDLModel getWsdlModel() {
15.99 + return mWsdlModel;
15.100 }
15.101 -
15.102 +
15.103 public SchemaTypeLoader getSchemaTypeLoader() {
15.104 return mSchemaTypeLoader;
15.105 }
15.106 @@ -119,15 +105,16 @@
15.107 wsdlSupportErrStr = s;
15.108 }
15.109
15.110 - private static SchemaTypeLoader loadSchemaTypes(String wsdlUrl) throws XmlException, SchemaException {
15.111 - HashMap schemaTable = new HashMap();
15.112 + private static SchemaTypeLoader loadSchemaTypes(String wsdlUrl)
15.113 + throws XmlException, SchemaException {
15.114 +
15.115 + Map<String, XmlObject> schemaTable = new HashMap<String, XmlObject>();
15.116 getSchemas(wsdlUrl, schemaTable, new ArrayList<String>());
15.117
15.118 - ArrayList schemaList = new ArrayList(schemaTable.values());
15.119 - // remove imports
15.120 - for (int i = 0, I = schemaList.size(); i < I; i++) {
15.121 - XmlObject s = (XmlObject)schemaList.get(i);
15.122 - removeImportAndInclude(s);
15.123 + List<XmlObject> schemaList =
15.124 + new ArrayList<XmlObject>(schemaTable.values());
15.125 + for (XmlObject schema : schemaList) {
15.126 + removeImportAndInclude(schema);
15.127 }
15.128
15.129 SchemaTypeLoader schemaTypes = loadSchemaTypes(schemaList);
15.130 @@ -154,7 +141,7 @@
15.131 try {
15.132 schemaList.add(XmlObject.Factory.parse(WsdlSupport.class.getResource(
15.133 "/org/netbeans/modules/compapp/test/wsdl/resources/soapEncoding.xsd"))); // NOI18N
15.134 - XmlObject [] schemaArray = (XmlObject[])schemaList.toArray(new XmlObject[0]);
15.135 + XmlObject[] schemaArray = (XmlObject[])schemaList.toArray(new XmlObject[0]);
15.136 return XmlBeans.loadXsd(schemaArray, options);
15.137 } catch (IOException e) {
15.138 //throw new SchemaException(e, errorList);
15.139 @@ -168,6 +155,7 @@
15.140 Map<String, XmlObject> schemaTable,
15.141 List<String> visitedSchemaWsdls)
15.142 throws SchemaException {
15.143 +
15.144 if(schemaTable.containsKey(wsdlUrl)) {
15.145 return;
15.146 }
15.147 @@ -187,14 +175,15 @@
15.148 options.setLoadStripWhitespace();
15.149 options.setLoadTrimTextBuffer();
15.150
15.151 - options.setSaveSyntheticDocumentElement(new QName("http://www.w3.org/2001/XMLSchema", "schema")); // NOI18N
15.152 + options.setSaveSyntheticDocumentElement(
15.153 + new QName("http://www.w3.org/2001/XMLSchema", "schema")); // NOI18N
15.154
15.155 XmlObject xmlObject = XmlObject.Factory.parse(new URL(wsdlUrl), options);
15.156
15.157 Document dom = (Document) xmlObject.getDomNode();
15.158 Node domNode = dom.getDocumentElement();
15.159 - if (domNode.getLocalName().equals("schema") // NOI18N
15.160 - && domNode.getNamespaceURI().equals(
15.161 + if (domNode.getLocalName().equals("schema") && // NOI18N
15.162 + domNode.getNamespaceURI().equals(
15.163 "http://www.w3.org/2001/XMLSchema")) { // NOI18N
15.164 result.put(wsdlUrl, xmlObject);
15.165 } else {
15.166 @@ -231,8 +220,16 @@
15.167
15.168 XmlObject[] schemaImports = xmlObject.selectPath(
15.169 "declare namespace s='http://www.w3.org/2001/XMLSchema' .//s:import/@schemaLocation"); // NOI18N
15.170 - for (int i = 0; i < schemaImports.length; i++) {
15.171 - String location = ((SimpleValue) schemaImports[i]).getStringValue();
15.172 + XmlObject[] schemaIncludes = xmlObject.selectPath(
15.173 + "declare namespace s='http://www.w3.org/2001/XMLSchema' .//s:include/@schemaLocation"); // NOI18N
15.174 + List<XmlObject> schemaImportsList = Arrays.asList(schemaImports);
15.175 + List<XmlObject> schemaIncludesList = Arrays.asList(schemaIncludes);
15.176 + List<XmlObject> schemaImportsAndIncludes = new ArrayList<XmlObject>();
15.177 + schemaImportsAndIncludes.addAll(schemaImportsList);
15.178 + schemaImportsAndIncludes.addAll(schemaIncludesList);
15.179 +
15.180 + for (XmlObject schemaImportOrInclude : schemaImportsAndIncludes) {
15.181 + String location = ((SimpleValue)schemaImportOrInclude).getStringValue();
15.182 if (location != null &&
15.183 // We will be adding soap encoding later. This is to
15.184 // avoid duplicate global type definition error.
15.185 @@ -246,21 +243,6 @@
15.186 }
15.187 }
15.188 }
15.189 -
15.190 - XmlObject[] schemaIncludes = xmlObject.selectPath(
15.191 - "declare namespace s='http://www.w3.org/2001/XMLSchema' .//s:include/@schemaLocation"); // NOI18N
15.192 - for (int i = 0; i < schemaIncludes.length; i++) {
15.193 - String location = ((SimpleValue) schemaIncludes[i]).getStringValue();
15.194 - if (location != null) {
15.195 - if (!location.startsWith("file:") && location.indexOf("://") <= 0) { // NOI18N
15.196 - location = resolveRelativeUrl(wsdlUrl, location);
15.197 - }
15.198 - if (!visitedSchemaWsdls.contains(location)) {
15.199 - visitedSchemaWsdls.add(location);
15.200 - getSchemas(location, schemaTable, visitedSchemaWsdls);
15.201 - }
15.202 - }
15.203 - }
15.204 }
15.205 schemaTable.putAll(result);
15.206 } catch (Exception e) {
15.207 @@ -285,14 +267,34 @@
15.208 }
15.209
15.210 private static String resolveRelativeUrl(String baseUrl, String url) {
15.211 - baseUrl = baseUrl.replaceAll("\\\\", "/");
15.212 - int ix = /*baseUrl.startsWith("file:") ? baseUrl.lastIndexOf(File.separatorChar) :*/ baseUrl.lastIndexOf('/'); // NOI18N
15.213 + if (baseUrl.startsWith("file:")) { // NOI18N
15.214 + FileObject fo = FileUtil.toFileObject(new File(baseUrl.substring(5)));
15.215 +
15.216 + try {
15.217 + ModelSource modelSourceOfSourceDocument =
15.218 + Utilities.createModelSource(fo, false);
15.219 +
15.220 + CatalogWriteModel model =
15.221 + CatalogWriteModelFactory.getInstance().getCatalogWriteModelForProject(fo);
15.222 +
15.223 + ModelSource modelSource =
15.224 + model.getModelSource(new URI(url), modelSourceOfSourceDocument);
15.225 + FileObject targetFO = modelSource.getLookup().lookup(FileObject.class);
15.226 + System.out.println(targetFO);
15.227 + return "file:" + targetFO.getPath();
15.228 + } catch (Exception e) {
15.229 + e.printStackTrace();
15.230 + }
15.231 + }
15.232 +
15.233 + baseUrl = baseUrl.replaceAll("\\\\", "/"); // NOI18N
15.234 + int ix = baseUrl.lastIndexOf('/'); // NOI18N
15.235 if (ix == -1) {
15.236 - ix = baseUrl.lastIndexOf('/');
15.237 + ix = baseUrl.lastIndexOf('/'); // NOI18N
15.238 }
15.239
15.240 while(url.startsWith("../")) { // NOI18N
15.241 - int ix2 = baseUrl.lastIndexOf('/', ix-1);
15.242 + int ix2 = baseUrl.lastIndexOf('/', ix-1); // NOI18N
15.243 if(ix2 == -1) {
15.244 break;
15.245 }