Complete update of the new BPEL wizard.
Addition of a reusable plug-in for WSDL import and parsing.
Addition of tests for the updated wizard and the new utilities.
diff --git a/plugins/org.eclipse.bpel.common.wsdl/.classpath b/plugins/org.eclipse.bpel.common.wsdl/.classpath
new file mode 100644
index 0000000..8a8f166
--- /dev/null
+++ b/plugins/org.eclipse.bpel.common.wsdl/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/plugins/org.eclipse.bpel.common.wsdl/.project b/plugins/org.eclipse.bpel.common.wsdl/.project
new file mode 100644
index 0000000..31027fb
--- /dev/null
+++ b/plugins/org.eclipse.bpel.common.wsdl/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.bpel.common.wsdl</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/plugins/org.eclipse.bpel.common.wsdl/META-INF/MANIFEST.MF b/plugins/org.eclipse.bpel.common.wsdl/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..6cecd3d
--- /dev/null
+++ b/plugins/org.eclipse.bpel.common.wsdl/META-INF/MANIFEST.MF
@@ -0,0 +1,20 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: SOA Commons for WSDL and XML Schemas
+Bundle-SymbolicName: org.eclipse.bpel.common.wsdl;singleton:=true
+Bundle-Version: 1.0.0.qualifier
+Bundle-Activator: org.eclipse.bpel.common.wsdl.SoaWsdlCommonPlugin
+Bundle-Vendor: Eclipse.org
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.eclipse.core.resources,
+ org.eclipse.ui.ide,
+ org.eclipse.xsd,
+ org.eclipse.wst.wsdl,
+ org.eclipse.emf.ecore.xmi,
+ javax.wsdl;bundle-version="1.5.1"
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Bundle-ActivationPolicy: lazy
+Export-Package: org.eclipse.bpel.common.wsdl.helpers,
+ org.eclipse.bpel.common.wsdl.importhelpers,
+ org.eclipse.bpel.common.wsdl.parsers
diff --git a/plugins/org.eclipse.bpel.common.wsdl/build.properties b/plugins/org.eclipse.bpel.common.wsdl/build.properties
new file mode 100644
index 0000000..e8bd68f
--- /dev/null
+++ b/plugins/org.eclipse.bpel.common.wsdl/build.properties
@@ -0,0 +1,7 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml,\
+ icons/,\
+ bin/
diff --git a/plugins/org.eclipse.bpel.common.wsdl/icons/obj16/importWsdl3.gif b/plugins/org.eclipse.bpel.common.wsdl/icons/obj16/importWsdl3.gif
new file mode 100644
index 0000000..921adcc
--- /dev/null
+++ b/plugins/org.eclipse.bpel.common.wsdl/icons/obj16/importWsdl3.gif
Binary files differ
diff --git a/plugins/org.eclipse.bpel.common.wsdl/plugin.xml b/plugins/org.eclipse.bpel.common.wsdl/plugin.xml
new file mode 100644
index 0000000..e2e260f
--- /dev/null
+++ b/plugins/org.eclipse.bpel.common.wsdl/plugin.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+ <extension
+ point="org.eclipse.ui.importWizards">
+ <category
+ id="org.eclipse.bpel.common.wsdl.wsdlCategory"
+ name="WSDL">
+ </category>
+ <wizard
+ category="org.eclipse.bpel.common.wsdl.wsdlCategory"
+ class="org.eclipse.bpel.common.wsdl.wizards.WsdlImportWizard"
+ icon="icons/obj16/importWsdl3.gif"
+ id="org.eclipse.bpel.common.wsdl.wsdlImportWizard"
+ name="WSDL">
+ </wizard>
+ </extension>
+
+</plugin>
diff --git a/plugins/org.eclipse.bpel.common.wsdl/src/org/eclipse/bpel/common/wsdl/SoaWsdlCommonPlugin.java b/plugins/org.eclipse.bpel.common.wsdl/src/org/eclipse/bpel/common/wsdl/SoaWsdlCommonPlugin.java
new file mode 100644
index 0000000..fd227b4
--- /dev/null
+++ b/plugins/org.eclipse.bpel.common.wsdl/src/org/eclipse/bpel/common/wsdl/SoaWsdlCommonPlugin.java
@@ -0,0 +1,111 @@
+/****************************************************************************
+ *
+ * Copyright (c) 2011, EBM WebSourcing
+ *
+ * This source code is available under agreement available at
+ * http://www.petalslink.com/legal/licenses/petals-studio
+ *
+ * You should have received a copy of the agreement along with this program.
+ * If not, write to EBM WebSourcing (4, rue Amelie - 31200 Toulouse, France).
+ *
+ *****************************************************************************/
+
+package org.eclipse.bpel.common.wsdl;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ * @author Vincent Zurczak - EBM WebSourcing
+ */
+public class SoaWsdlCommonPlugin extends AbstractUIPlugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.eclipse.bpel.common.wsdl"; //$NON-NLS-1$
+
+ // The shared instance
+ private static SoaWsdlCommonPlugin plugin;
+
+
+ /**
+ * The constructor
+ */
+ public SoaWsdlCommonPlugin() {
+ // nothing
+ }
+
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin
+ * #start(org.osgi.framework.BundleContext)
+ */
+ @Override
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ }
+
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin
+ * #stop(org.osgi.framework.BundleContext)
+ */
+ @Override
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+
+ /**
+ * Returns the shared instance
+ * @return the shared instance
+ */
+ public static SoaWsdlCommonPlugin getDefault() {
+ return plugin;
+ }
+
+
+ /**
+ * Logs an exception.
+ * @param e the exception to log
+ * @param severity the severity, given as one of the {@link IStatus} constants
+ */
+ public static void log( Exception e, int severity ) {
+
+ String msg = e.getMessage();
+ if( msg == null || msg.trim().length() == 0 )
+ msg = "An error occurred.";
+
+ IStatus status = new Status( severity, PLUGIN_ID, msg, e );
+ getDefault().getLog().log( status );
+ }
+
+
+ /**
+ * Logs a message.
+ * @param message the message to log
+ * @param severity the severity, given as one of the {@link IStatus} constants
+ */
+ public static void log( String message, int severity ) {
+ IStatus status = new Status( severity, PLUGIN_ID, message );
+ getDefault().getLog().log( status );
+ }
+
+
+ /**
+ * Logs a message and an exception.
+ * @param e the exception to log
+ * @param severity the severity, given as one of the {@link IStatus} constants
+ * @param message the message to log
+ */
+ public static void log( Exception e, int severity, String message ) {
+ IStatus status = new Status( severity, PLUGIN_ID, message, e );
+ getDefault().getLog().log( status );
+ }
+}
diff --git a/plugins/org.eclipse.bpel.common.wsdl/src/org/eclipse/bpel/common/wsdl/helpers/UriAndUrlHelper.java b/plugins/org.eclipse.bpel.common.wsdl/src/org/eclipse/bpel/common/wsdl/helpers/UriAndUrlHelper.java
new file mode 100644
index 0000000..39f5fd6
--- /dev/null
+++ b/plugins/org.eclipse.bpel.common.wsdl/src/org/eclipse/bpel/common/wsdl/helpers/UriAndUrlHelper.java
@@ -0,0 +1,276 @@
+/****************************************************************************
+ *
+ * Copyright (c) 2008-2011, EBM WebSourcing
+ *
+ * This source code is available under agreement available at
+ * http://www.petalslink.com/legal/licenses/petals-studio
+ *
+ * You should have received a copy of the agreement along with this program.
+ * If not, write to EBM WebSourcing (4, rue Amelie - 31200 Toulouse, France).
+ *
+ *****************************************************************************/
+
+package org.eclipse.bpel.common.wsdl.helpers;
+
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.Date;
+
+import org.eclipse.bpel.common.wsdl.SoaWsdlCommonPlugin;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
+
+/**
+ * A set of helpers for URIs and URLs.
+ * @author Vincent Zurczak - EBM WebSourcing
+ */
+public class UriAndUrlHelper {
+
+ /**
+ * Builds an URI from an URL (with an handle for URLs not compliant with RFC 2396).
+ * @param url
+ * @return
+ */
+ public static URI urlToUri( URL url ) {
+
+ URI uri;
+ try {
+ // Possible failing step.
+ uri = url.toURI();
+
+ } catch( Exception e ) {
+ // URL did not comply with RFC 2396 => illegal un-escaped characters.
+ try {
+ uri = new URI(
+ url.getProtocol(), url.getUserInfo(),
+ url.getHost(), url.getPort(),
+ url.getPath(), url.getQuery(), url.getRef());
+ } catch( Exception e1 ) {
+ // No automatic repair.
+ throw new IllegalArgumentException( "Broken URL: " + url );
+ }
+ }
+
+ uri = uri.normalize();
+ return uri;
+ }
+
+
+ /**
+ * Builds an URI from an URL string (with an handle for URLs not compliant with RFC 2396).
+ * @param urlAsString
+ * @return
+ */
+ public static URI urlToUri( String urlAsString ) {
+
+ try {
+ URL url = new URL( urlAsString );
+ return urlToUri( url );
+
+ } catch( Exception e ) {
+ // e.printStackTrace();
+ }
+
+ throw new IllegalArgumentException( "Broken URL: " + urlAsString );
+ }
+
+
+ /**
+ * Extracts the file name from a URI or URL given as a string.
+ * @param uriAsString the URI or URL given as a string
+ * @return the file name (never null)
+ */
+ public static String extractFileName( String uriAsString ) {
+
+ String fileName = uriAsString;
+ if( fileName.endsWith( "/" ))
+ fileName = fileName.substring( 0, fileName.length() - 1 );
+
+ int index = fileName.lastIndexOf( '/' );
+ if( index != -1 )
+ fileName = fileName.substring( ++ index );
+
+ // Handle cases like "jsp?value="
+ index = fileName.lastIndexOf( '?' );
+ if( index != -1 )
+ fileName = fileName.substring( ++ index );
+
+ // Handle empty values
+ if( fileName.trim().length() == 0 )
+ fileName = "importedFile__" + new Date().getTime();
+
+ return fileName;
+ }
+
+
+ /**
+ * Builds an URI from an URI and a suffix.
+ *
+ * <p>
+ * This suffix can be an absolute URL, or a relative path
+ * with respect to the first URI. In this case, the suffix is resolved
+ * with respect to the URI.
+ * </p>
+ * <p>
+ * If the suffix is already an URL, its is returned.<br />
+ * If the suffix is a relative file path and cannot be resolved, an exception is thrown.
+ * </p>
+ * <p>
+ * The returned URI is normalized.
+ * </p>
+ *
+ * @param referenceUri the reference URI
+ * @param uriSuffix the URI suffix (not null)
+ * @return the new URI
+ * @throws URISyntaxException if the resolution failed
+ */
+ public static URI buildNewURI( URI referenceUri, String uriSuffix ) throws URISyntaxException {
+
+ if( uriSuffix == null )
+ throw new NullPointerException( "The URI suffix cannot be null." );
+
+ uriSuffix = uriSuffix.replaceAll( "\\\\", "/" );
+ URI importUri = null;
+ try { // Absolute URL ?
+ importUri = urlToUri( new URL( uriSuffix ));
+
+ } catch( Exception e ) {
+ try { // Relative URL ?
+ importUri = referenceUri.resolve( new URI( null, uriSuffix, null ));
+
+ } catch( Exception e2 ) {
+ String msg =
+ "An URI could not be built from the URI " + referenceUri.toString()
+ + " and the suffix " + uriSuffix + ".";
+ throw new URISyntaxException( msg, e2.getMessage());
+ }
+ }
+
+ return importUri.normalize();
+ }
+
+
+ /**
+ * Determines whether a string is an absolute URI.
+ * @param uriAsString the potential URI, as a string
+ * @return true if it is an absolute URI, false otherwise or if it is not a valid URI
+ */
+ public static boolean isAbsoluteUri( String uriAsString ) {
+
+ boolean result;
+ try {
+ URI uri = urlToUri( uriAsString );
+ result = uri.isAbsolute();
+
+ } catch( Exception e ) {
+ result = false;
+ }
+
+ return result;
+ }
+
+
+ /**
+ * Returns the relative position of <code>uri</code> with respect to <code>originUri</code>.
+ *
+ * @param originUri the URI which acts as the <i>origin</i>.
+ * @param uri the URI whose relative path must be computed with respect to originUri.
+ * @return the relative path of <code>uri</code> with respect to originUri, if they
+ * are on the same host and have a same scheme, or <code>uri<code> otherwise.
+ */
+ public static URI getRelativeLocationToUri( URI originUri, URI uri ) {
+
+ URI result = uri;
+ try {
+ originUri = UriAndUrlHelper.urlToUri( originUri.toURL());
+ uri = UriAndUrlHelper.urlToUri( uri.toURL());
+ URI relativeUri = originUri.relativize( uri ).normalize();
+ if( ! uri.equals( relativeUri )) {
+ result = relativeUri;
+ }
+ else {
+ // Do they have the same scheme?
+ String originScheme = originUri.getScheme();
+ String scheme = uri.getScheme();
+ boolean sameScheme = false;
+ if( originScheme != null )
+ sameScheme = originScheme.equals( scheme );
+ else
+ sameScheme = scheme == null;
+
+ // Do they have the same host?
+ String originHost = originUri.getHost();
+ String host = uri.getHost();
+ boolean sameHost = false;
+ if( originHost != null )
+ sameHost = originHost.equals( host );
+ else
+ sameHost = host == null;
+
+ // Make a special treatment for "file" scheme.
+ // Are they on the same disk partition?
+ // If no, then there is no relative path to compute.
+ boolean samePartition = true;
+ if( sameScheme && "file".equalsIgnoreCase( originScheme )) {
+
+ String originDevice = new Path( originUri.getPath()).getDevice();
+ String device = new Path( uri.getPath()).getDevice();
+ if( originDevice != null )
+ samePartition = originDevice.equals( device );
+ else
+ samePartition = device == null;
+ }
+
+ // If yes for both, we can define a relative location.
+ // The only reason why URI#relativize( ... ) could have failed previously,
+ // is because this method only works when "uri" is a child of "originUri".
+ // Otherwise, we have to insert ".." when required.
+ if( sameScheme && sameHost && samePartition ) {
+ String originPath = originUri.toString().replaceAll( "\\\\", "/" );
+ String path = uri.toString().replaceAll( "\\\\", "/" );
+
+ // Split the paths
+ String[] originParts = originPath.split( "/" );
+ String[] fileParts = path.split( "/" );
+
+ int matchSegmentsCpt = 0;
+ for( int i=0; i<originParts.length; i++ ) {
+ if( i >= fileParts.length )
+ break;
+
+ String otherSegment = fileParts[ i ];
+ String segment = originParts[ i ];
+ if( segment.equalsIgnoreCase( otherSegment ))
+ matchSegmentsCpt ++;
+ else
+ break;
+ }
+
+ // Build the relative location
+ StringBuffer relativePath = new StringBuffer();
+ if( matchSegmentsCpt > 0 ) {
+
+ for( int i=matchSegmentsCpt; i<originParts.length - 1; i++ )
+ relativePath.append( "../" );
+ for( int i=matchSegmentsCpt; i<fileParts.length - 1; i++ )
+ relativePath.append( fileParts[ i ] + "/" );
+ relativePath.append( fileParts[ fileParts.length - 1 ]);
+
+ // Remove extra ".." and "."
+ result = new URI( null, relativePath.toString(), null );
+ }
+ }
+ }
+
+ } catch( URISyntaxException e ) {
+ SoaWsdlCommonPlugin.log( e, IStatus.ERROR );
+
+ } catch( MalformedURLException e ) {
+ SoaWsdlCommonPlugin.log( e, IStatus.ERROR );
+ }
+
+ return result;
+ }
+}
diff --git a/plugins/org.eclipse.bpel.common.wsdl/src/org/eclipse/bpel/common/wsdl/importhelpers/WsdlImportBean.java b/plugins/org.eclipse.bpel.common.wsdl/src/org/eclipse/bpel/common/wsdl/importhelpers/WsdlImportBean.java
new file mode 100644
index 0000000..174b974
--- /dev/null
+++ b/plugins/org.eclipse.bpel.common.wsdl/src/org/eclipse/bpel/common/wsdl/importhelpers/WsdlImportBean.java
@@ -0,0 +1,116 @@
+/******************************************************************************
+ * Copyright (c) 2011, EBM WebSourcing
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * EBM WebSourcing - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.bpel.common.wsdl.importhelpers;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+
+/**
+ * A bean to store information about an import in a WSDL or XML schema.
+ * <p>
+ * Package visibility.
+ * </p>
+ *
+ * @author Vincent Zurczak - EBM WebSourcing
+ */
+class WsdlImportBean {
+
+ private boolean analyzed = false;
+ private String originUri;
+ private String relativePathToTargetDirectory;
+ private final Map<String,String> importDeclarationToImportFullUri;
+
+
+
+ /**
+ * Constructor.
+ */
+ public WsdlImportBean() {
+ this.importDeclarationToImportFullUri = new HashMap<String,String> ();
+ }
+
+
+ /**
+ * @return the originUri
+ */
+ public String getOriginUri() {
+ return this.originUri;
+ }
+
+
+ /**
+ * @param originUri the originUri to set
+ */
+ public void setOriginUri( String originUri ) {
+ this.originUri = originUri;
+ }
+
+
+ /**
+ * @return the analyzed
+ */
+ public boolean wasAnalyzed() {
+ return this.analyzed;
+ }
+
+
+ /**
+ * @param analyzed the analyzed to set
+ */
+ public void setAnalyzed( boolean analyzed ) {
+ this.analyzed = analyzed;
+ }
+
+
+ /**
+ * @return the relativePathToTargetDirectory
+ */
+ public String getRelativePathToTargetDirectory() {
+ return this.relativePathToTargetDirectory;
+ }
+
+
+ /**
+ * @param relativePathToTargetDirectory the relativePathToTargetDirectory to set
+ */
+ public void setRelativePathToTargetDirectory(
+ String relativePathToTargetDirectory ) {
+ this.relativePathToTargetDirectory = relativePathToTargetDirectory;
+ }
+
+
+ /**
+ * @param importDeclaration the import declaration
+ * @param importFullUri the full URI of the import
+ * @see java.util.Map#put(java.lang.Object, java.lang.Object)
+ * <p>
+ * If the file being parsed is located at <i>http://192.168.1.17/WSDL/myWsdl.wsdl</i>
+ * and associated to this instance of {@link WsdlImportBean},
+ * then an import declaration make be <i>subDir/schemes.xsd</i> and the full URI
+ * be <i>http://192.168.1.17/WSDL/subDir/schemes.xsd</i>.
+ * </p>
+ */
+ public void registerImport( String importDeclaration, String importFullUri ) {
+ this.importDeclarationToImportFullUri.put( importDeclaration, importFullUri );
+ }
+
+
+ /**
+ * @return the map's content that associates import declarations (keys) and full URIs( values).
+ * @see java.util.Map#entrySet()
+ */
+ public Set<Entry<String, String>> entrySet() {
+ return this.importDeclarationToImportFullUri.entrySet();
+ }
+}
diff --git a/plugins/org.eclipse.bpel.common.wsdl/src/org/eclipse/bpel/common/wsdl/importhelpers/WsdlImportHelper.java b/plugins/org.eclipse.bpel.common.wsdl/src/org/eclipse/bpel/common/wsdl/importhelpers/WsdlImportHelper.java
new file mode 100644
index 0000000..2715122
--- /dev/null
+++ b/plugins/org.eclipse.bpel.common.wsdl/src/org/eclipse/bpel/common/wsdl/importhelpers/WsdlImportHelper.java
@@ -0,0 +1,410 @@
+/****************************************************************************
+ *
+ * Copyright (c) 2008-2011, EBM WebSourcing
+ *
+ * This source code is available under agreement available at
+ * http://www.petalslink.com/legal/licenses/petals-studio
+ *
+ * You should have received a copy of the agreement along with this program.
+ * If not, write to EBM WebSourcing (4, rue Amelie - 31200 Toulouse, France).
+ *
+ *****************************************************************************/
+
+package org.eclipse.bpel.common.wsdl.importhelpers;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.UnsupportedEncodingException;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URLConnection;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.eclipse.bpel.common.wsdl.SoaWsdlCommonPlugin;
+import org.eclipse.bpel.common.wsdl.helpers.UriAndUrlHelper;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+import org.xml.sax.SAXException;
+
+/**
+ * A class that can import a WSDL (1.1 and 2.0) and all its dependencies (XSD, XML, WSDL).
+ * @author Vincent Zurczak - EBM WebSourcing
+ */
+public class WsdlImportHelper {
+
+ public final static String RELOCATED_DIRECTORY = "relocated";
+
+ public final static String WSDL20_NAMESPACE = "http://www.w3.org/ns/wsdl";
+ public final static String WSDL11_NAMESPACE = "http://schemas.xmlsoap.org/wsdl/";
+ public final static String SCHEMA_NAMESPACE = "http://www.w3.org/2001/XMLSchema";
+ public final static String XSI_NAMESPACE = "http://http://www.w3.org/2001/XMLSchema-instance";
+
+ private final DocumentBuilder documentBuilder;
+
+
+
+ /**
+ * Constructor.
+ * @throws ParserConfigurationException if a parser could not be created
+ */
+ public WsdlImportHelper() throws ParserConfigurationException {
+
+ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+ factory.setNamespaceAware( true );
+ this.documentBuilder = factory.newDocumentBuilder();
+ }
+
+
+ /**
+ * Imports a WSDL or a XSD will all its dependencies.
+ * @param targetDirectory
+ * @param wsdlUris
+ * @return
+ * @throws IOException if a resource could not be read or imported
+ * @throws IllegalArgumentException if an import could not be resolved into an URI
+ * @throws URISyntaxException if an import could not be resolved into an URI
+ * @throws SAXException if an import could not be parsed
+ */
+ public Map<String,File> importWsdlOrXsdAndDependencies( File targetDirectory, String... wsdlUris )
+ throws IllegalArgumentException, IOException, URISyntaxException, SAXException {
+
+ // Analyze the resources
+ Map<String,WsdlImportBean> resourceUriToWIBean = new HashMap<String,WsdlImportBean> ();
+ analyzeResources( resourceUriToWIBean, null, wsdlUris );
+
+
+ // Now, we have to find the target path and solve conflicts in target files
+ Set<File> targetFiles = new HashSet<File> ();
+ IPath rootPath = new Path( targetDirectory.getAbsolutePath());
+ for( Map.Entry<String,WsdlImportBean> entry : resourceUriToWIBean.entrySet()) {
+
+ // Get the real relative file path
+ String relativeFilePath = entry.getValue().getRelativePathToTargetDirectory();
+ if( relativeFilePath.length() == 0 )
+ relativeFilePath = UriAndUrlHelper.extractFileName( entry.getKey());
+
+ // Imported files which are above the target directory will be put inside a specific directory
+ IPath path = rootPath.append( relativeFilePath );
+ if( ! rootPath.isPrefixOf( path ))
+ relativeFilePath = RELOCATED_DIRECTORY + "/" + UriAndUrlHelper.extractFileName( entry.getKey());
+
+ // Prevent conflicts with existing files and files to be written
+ File targetFile;
+ String newRelativeFilePath = relativeFilePath;
+ int cpt = 0;
+ while(( targetFile = new File( targetDirectory, newRelativeFilePath )).exists()
+ || targetFiles.contains( targetFile )) {
+ newRelativeFilePath = insertSuffixBeforeFileExtension( relativeFilePath, "_" + cpt );
+ cpt ++;
+ }
+
+ entry.getValue().setRelativePathToTargetDirectory( newRelativeFilePath );
+ targetFiles.add( targetFile );
+ }
+
+
+ // Last steps:
+ // Resolve the final target files
+ // And update the import declarations in the files
+ // And import the file
+ Map<String,File> originUriToTargetFile = new HashMap<String,File> ();
+ for( WsdlImportBean bean : resourceUriToWIBean.values()) {
+ File targetFile = new File( targetDirectory, bean.getRelativePathToTargetDirectory());
+ URI uri = UriAndUrlHelper.urlToUri( bean.getOriginUri());
+ String resourceContent = readResourceContent( uri );
+
+ for( Map.Entry<String,String> entry : bean.entrySet()) {
+ WsdlImportBean importBean = resourceUriToWIBean.get( entry.getValue());
+ File importFile = new File( targetDirectory, importBean.getRelativePathToTargetDirectory());
+ String relLoc = getRelativeLocationToFile( targetFile, importFile );
+
+ // Coherence is guaranteed because the keys are sorted by length, from the longer to the shorter
+ resourceContent = resourceContent.replace( entry.getKey(), relLoc );
+ }
+
+ if( ! targetFile.getParentFile().exists()
+ && ! targetFile.getParentFile().mkdirs())
+ throw new IOException( "Could not create " + targetFile.getParentFile());
+
+ OutputStream os = new FileOutputStream( targetFile );
+ ByteArrayInputStream is;
+ try {
+ is = new ByteArrayInputStream( resourceContent.getBytes( "UTF-8" ));
+ } catch( UnsupportedEncodingException e ) {
+ is = new ByteArrayInputStream( resourceContent.getBytes());
+ }
+
+ copyStream( is, os );
+ os.close ();
+
+ originUriToTargetFile.put( bean.getOriginUri(), targetFile );
+ }
+
+ return originUriToTargetFile;
+ }
+
+
+ /**
+ * Analyzes a set of resources and gets all the import declarations.
+ * @param wsdlUris a set of URIs to WSDL or XML schemas
+ * @param referentUri the URI to use to determine the relative location of the target file
+ * @param resourceUriToWIBean a map (key = resource full URI, value = {@link WsdlImportBean})
+ * @throws URISyntaxException if an import could not be resolved to an URI
+ * @throws SAXException if an import could not be parsed
+ * @throws IOException if an import could not be read
+ */
+ private void analyzeResources( Map<String,WsdlImportBean> resourceUriToWIBean, URI referentUri, String... wsdlUris )
+ throws URISyntaxException, IOException, SAXException {
+
+ for( String wsdlUri : wsdlUris ) {
+
+ // Original URI: add it to the root
+ if( ! resourceUriToWIBean.containsKey( wsdlUri )) {
+ WsdlImportBean bean = new WsdlImportBean();
+ bean.setOriginUri( wsdlUri );
+ bean.setRelativePathToTargetDirectory( "" );
+ resourceUriToWIBean.put( wsdlUri, bean );
+ }
+
+ // Now, parse it and get its dependencies
+ WsdlImportBean bean = resourceUriToWIBean.get( wsdlUri );
+ bean.setAnalyzed( true );
+ URI uri = UriAndUrlHelper.urlToUri( wsdlUri );
+ referentUri = referentUri != null ? referentUri : uri;
+
+ Set<String> brutImports = findImports( uri );
+ for( String brutImport : brutImports ) {
+
+ // Absolute URI: we will put them at the same level than the original URI
+ URI importFullUri = null;
+ String importFullUriAsString = null;
+ if( UriAndUrlHelper.isAbsoluteUri( brutImport ))
+ importFullUriAsString = brutImport;
+ else {
+ importFullUri = UriAndUrlHelper.buildNewURI( uri, brutImport );
+ importFullUriAsString = importFullUri.toString();
+ }
+
+ // Keep a trace of the import declaration
+ bean.registerImport( brutImport, importFullUriAsString );
+
+ // Remember the import for further processing
+ if( ! resourceUriToWIBean.containsKey( importFullUriAsString )) {
+ WsdlImportBean childBean = new WsdlImportBean();
+ childBean.setOriginUri( importFullUriAsString );
+
+ URI relativeUri = UriAndUrlHelper.getRelativeLocationToUri( referentUri, importFullUri );
+ String relPath = relativeUri.toString();
+ if( UriAndUrlHelper.isAbsoluteUri( relPath ))
+ relPath = "";
+
+ childBean.setRelativePathToTargetDirectory( relPath );
+ resourceUriToWIBean.put( importFullUriAsString, childBean );
+ }
+
+ // And we need to process recursively all the new imports
+ WsdlImportBean childBean = resourceUriToWIBean.get( importFullUriAsString );
+ if( ! childBean.wasAnalyzed())
+ analyzeResources( resourceUriToWIBean, referentUri, importFullUriAsString );
+ }
+ }
+ }
+
+
+ /**
+ * Finds all the import declarations in a given document.
+ * @param referencerUri the URI of the XML file
+ * @return a non-list of import declarations (as found in the document)
+ * @throws IOException if an import could not be read
+ * @throws SAXException if an import could not be parsed
+ */
+ private Set<String> findImports( final URI referencerUri ) throws IOException, SAXException {
+
+ Set<String> result = new HashSet<String> ();
+
+ // Parse the XML document
+ URLConnection connection = referencerUri.toURL().openConnection();
+ InputStream is = connection.getInputStream();
+ Document referencerDocument = this.documentBuilder.parse( is );
+
+
+ // Check the root element is a valid one...
+ Element docRoot = referencerDocument.getDocumentElement();
+ String rootNs = docRoot.getNamespaceURI();
+ String rootName = docRoot.getLocalName();
+ int index = rootName.lastIndexOf( ':' );
+ if( index != -1 )
+ rootName = rootName.substring( ++ index );
+
+
+ // ... and if so, get its import declarations
+ if( "definitions".equals( rootName ) && WSDL11_NAMESPACE.equals( rootNs )
+ || "description".equals( rootName ) && WSDL20_NAMESPACE.equals( rootNs )
+ || "schema".equals( rootName ) && SCHEMA_NAMESPACE.equals( rootNs )) {
+ result.addAll( findImports( docRoot ));
+ }
+
+ return result;
+ }
+
+
+ /**
+ * Gets all the import declarations from a XML document (XSD, WSDL).
+ * @param docRoot the root element
+ * @return a non-null list of import locations, as defined in the document
+ */
+ private Set<String> findImports( Element docRoot ) {
+
+ // Get the imports
+ List<NodeList> importElements = new ArrayList<NodeList> ();
+ importElements.add( docRoot.getElementsByTagNameNS( WSDL11_NAMESPACE, "import" ));
+ importElements.add( docRoot.getElementsByTagNameNS( WSDL20_NAMESPACE, "import" ));
+ importElements.add( docRoot.getElementsByTagNameNS( WSDL20_NAMESPACE, "include" ));
+ importElements.add( docRoot.getElementsByTagNameNS( SCHEMA_NAMESPACE, "import" ));
+ importElements.add( docRoot.getElementsByTagNameNS( SCHEMA_NAMESPACE, "include" ));
+
+ // Now, get the import locations
+ Set<String> importLocations = new HashSet<String> ();
+ for( NodeList nodeList : importElements ) {
+ for( int i=0; i<nodeList.getLength(); i++ ) {
+
+ Element importElement = (Element) nodeList.item( i );
+ String location = importElement.hasAttribute( "location" ) ? importElement.getAttribute( "location" ) : null;
+ if( location == null ) {
+ location = importElement.getAttribute( "schemaLocation" );
+ int index = location.lastIndexOf( ' ' );
+ if( index != -1 )
+ location = location.substring( ++ index );
+ }
+
+ if( location != null )
+ importLocations.add( location );
+ else
+ SoaWsdlCommonPlugin.log( "An import location could not be found.", IStatus.WARNING );
+ }
+ }
+
+ return importLocations;
+ }
+
+
+ /**
+ * Return the relative position of <code>file</code> with respect to originFile.
+ * <p>
+ * Legacy and more complete than {@link #getBasicRelativePath(File, File)}.
+ * </p>
+ *
+ * @param originFile the absolute file which acts as the <i>origin</i>.
+ * @param file the file whose relative path must be computed with respect to originFile.
+ * @return the relative path of <code>file</code> with respect to originFile.
+ * @see UriUtils#getRelativeLocationToUri(URI, URI)
+ */
+ private static String getRelativeLocationToFile( File originFile, File file ) {
+
+ String result = file.getAbsolutePath();
+ try {
+ URI originUri = UriAndUrlHelper.urlToUri( originFile.toURI().toURL());
+ URI fileUri = UriAndUrlHelper.urlToUri( file.toURI().toURL());
+ result = UriAndUrlHelper.getRelativeLocationToUri( originUri, fileUri ).toString();
+
+ } catch( MalformedURLException e ) {
+ SoaWsdlCommonPlugin.log( e, IStatus.ERROR );
+ }
+
+ return result;
+ }
+
+
+ /**
+ * Reads the content of a resource and returns it as a string.
+ * <p>
+ * The content is tried to be read with UTF-8 encoding.
+ * If it fails, the default system encoding is used.
+ * </p>
+ *
+ * @param uri the URI of the resource whose content must be loaded
+ * @return the resource's content
+ * @throws IOException if the resource's content could not be read
+ */
+ private static String readResourceContent( URI uri ) throws IOException {
+
+ String result = null;
+ ByteArrayOutputStream os = new ByteArrayOutputStream();
+ InputStream is = null;
+ try {
+ is = uri.toURL().openStream();
+ copyStream( is, os );
+
+ } finally {
+ if( is != null )
+ is.close();
+ }
+
+ try {
+ result = os.toString( "UTF-8" );
+ } catch( UnsupportedEncodingException e ) {
+ result = os.toString();
+ }
+
+ return result;
+ }
+
+
+ /**
+ * Copies the content from in into os.
+ * <p>
+ * Neither <i>in</i> nor <i>os</i> are closed by this method.<br />
+ * They must be explicitly closed after this method is called.
+ * </p>
+ *
+ * @param in
+ * @param os
+ * @throws IOException
+ */
+ private static void copyStream( InputStream in, OutputStream os ) throws IOException {
+
+ byte[] buf = new byte[ 1024 ];
+ int len;
+ while((len = in.read( buf )) > 0) {
+ os.write( buf, 0, len );
+ }
+ }
+
+
+ /**
+ * Inserts a suffix before the file extension in a given string.
+ * @param string a string, file name or file path
+ * @param suffix a suffix to insert before the file extension
+ * @return a new string
+ */
+ private static String insertSuffixBeforeFileExtension( String string, String suffix ) {
+
+ int index = string.lastIndexOf( '.' );
+ String result;
+ if( index == -1 )
+ result = string + suffix;
+ else
+ result = string.substring( 0, index ) + suffix + string.substring( index );
+
+ return result;
+ }
+}
diff --git a/plugins/org.eclipse.bpel.common.wsdl/src/org/eclipse/bpel/common/wsdl/parsers/WsdlParser.java b/plugins/org.eclipse.bpel.common.wsdl/src/org/eclipse/bpel/common/wsdl/parsers/WsdlParser.java
new file mode 100644
index 0000000..6cf0f8d
--- /dev/null
+++ b/plugins/org.eclipse.bpel.common.wsdl/src/org/eclipse/bpel/common/wsdl/parsers/WsdlParser.java
@@ -0,0 +1,185 @@
+/******************************************************************************
+ * Copyright (c) 2011, EBM WebSourcing
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * EBM WebSourcing - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.bpel.common.wsdl.parsers;
+
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.wst.wsdl.Definition;
+import org.eclipse.wst.wsdl.Import;
+import org.eclipse.wst.wsdl.WSDLPackage;
+import org.eclipse.wst.wsdl.internal.util.WSDLResourceFactoryImpl;
+
+/**
+ * A set of utilities to parse WSDL definitions and accounting for file imports.
+ * <p>
+ * This class aims at providing more features than the WSDL meta-model (from WTP)
+ * or than WSDL4j. The difference resides in the support of resource imports.
+ * </p>
+ * <p>
+ * The implementation is currently based on the EMF meta-model for WSDL.
+ * </p>
+ *
+ * @author Vincent Zurczak - EBM WebSourcing
+ */
+public class WsdlParser {
+
+ /**
+ * Loads a WSDL definition.
+ * @param emfUri an EMF URI
+ * @param resourceSet a resource set
+ * @return an instance of {@link Definition}
+ * <p>
+ * This object does not support inclusions of WSDL files.
+ * It means imported WSDL definitions must be parsed separately.
+ * Note that XML schema inclusions are correctly supported.
+ * </p>
+ */
+ public static Definition loadWsdlDefinition( URI emfUri, ResourceSet resourceSet ) {
+ Resource resource = resourceSet.getResource( emfUri, true );
+ return (Definition) resource.getContents().iterator().next();
+ }
+
+
+ /**
+ * Loads a set of WSDL definition from one document.
+ * <p>
+ * The set includes the other definitions that come from the imports.
+ * </p>
+ *
+ * @see #findAllWsdlDefinitions(Definition)
+ * @param emfUri an EMF URI
+ * @param resourceSet a resource set
+ * @return an instance of {@link Definition}
+ * <p>
+ * This object supports inclusions of WSDL and XML Schema.
+ * XML schema inclusions are supported natively by the Definition object.
+ * WSDL inclusions are supported because every WSDL import results in a Definition instance.
+ * </p>
+ * <p>
+ * This method handles cyclic inclusions.
+ * </p>
+ */
+ public static Collection<Definition> loadAllWsdlDefinitions( URI emfUri, ResourceSet resourceSet ) {
+ Resource resource = resourceSet.getResource( emfUri, true );
+ Definition def = (Definition) resource.getContents().iterator().next();
+ return findAllWsdlDefinitions( def );
+ }
+
+
+ /**
+ * Finds all the referenced WSDL definitions from one already loaded definition.
+ * <p>
+ * The set includes the other definitions that come from the imports.
+ * </p>
+ *
+ * @param alreadyLoadedDefinition a WSDL definition
+ * @return an instance of {@link Definition}
+ * <p>
+ * This object supports inclusions of WSDL and XML Schema.
+ * XML schema inclusions are supported natively by the Definition object.
+ * WSDL inclusions are supported because every WSDL import results in a Definition instance.
+ * </p>
+ * <p>
+ * This method handles cyclic inclusions.
+ * </p>
+ */
+ public static Collection<Definition> findAllWsdlDefinitions( Definition alreadyLoadedDefinition ) {
+
+ // Add the initial definition
+ Set<Definition> definitions = new HashSet<Definition> ();
+ definitions.add( alreadyLoadedDefinition );
+
+ // Process the imports
+ processImports( alreadyLoadedDefinition.getImports(), definitions );
+
+ return definitions;
+ }
+
+
+ /**
+ * Checks whether a definition seems valid or not.
+ * <p>
+ * The need for such a method results from the following discovery: when you load
+ * a WSDL 2.0 with the EMF meta-model, no error is thrown. Instead, a definition is
+ * created but it contains no information.
+ * </p>
+ *
+ * @param def a WSDL definition
+ * @return true if the definition seems valid, or false if it is definitely not a valid one
+ */
+ public static boolean seemsValidDefinition( Definition def ) {
+
+ return def.getBindings().size() != 0
+ || def.getPortTypes().size() != 0
+ || def.getServices().size() != 0
+ || def.getImports().size() != 0
+ || def.getTypes() != null;
+ }
+
+
+ /**
+ * Creates a resource set to parse WSDL definitions.
+ * <p>
+ * Note that WSDL extensions, such as partner link types, are not supported.
+ * Their support must be added in the resource set.
+ * </p>
+ *
+ * @return a resource set to parse WSDL
+ */
+ public static ResourceSet createBasicResourceSetForWsdl() {
+
+ ResourceSet resourceSet = XmlSchemaParser.createBasicResourceSetForXmlSchema();
+ resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put( "wsdl", new WSDLResourceFactoryImpl());
+ resourceSet.getPackageRegistry().put( WSDLPackage.eNS_URI, WSDLPackage.eINSTANCE );
+
+ return resourceSet;
+ }
+
+
+ /**
+ * Finds the definitions from imports and processes them recursively.
+ * @param imports a map of imports (see {@link Definition#getImports()})
+ * @param definitions a list of definitions, found from import declarations
+ */
+ private static void processImports( Map<?,?> imports, Collection<Definition> definitions ) {
+
+ for( Object o : imports.values()) {
+
+ // Case "java.util.list"
+ if( o instanceof List<?> ) {
+ for( Object oo : ((List<?>) o)) {
+ Definition d = ((Import) oo).getEDefinition();
+ if( d != null && ! definitions.contains( d )) {
+ definitions.add( d );
+ processImports( d.getImports(), definitions );
+ }
+ }
+ }
+
+ // Case "org.eclipse.wst.Definition"
+ else if( o instanceof Definition ) {
+ Definition d = (Definition) o;;
+ if( ! definitions.contains( d )) {
+ definitions.add( d );
+ processImports( d.getImports(), definitions );
+ }
+ }
+ }
+ }
+}
diff --git a/plugins/org.eclipse.bpel.common.wsdl/src/org/eclipse/bpel/common/wsdl/parsers/XmlSchemaParser.java b/plugins/org.eclipse.bpel.common.wsdl/src/org/eclipse/bpel/common/wsdl/parsers/XmlSchemaParser.java
new file mode 100644
index 0000000..6df8f93
--- /dev/null
+++ b/plugins/org.eclipse.bpel.common.wsdl/src/org/eclipse/bpel/common/wsdl/parsers/XmlSchemaParser.java
@@ -0,0 +1,62 @@
+/******************************************************************************
+ * Copyright (c) 2011, EBM WebSourcing
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * EBM WebSourcing - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.bpel.common.wsdl.parsers;
+
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+import org.eclipse.emf.ecore.xmi.impl.XMLResourceFactoryImpl;
+import org.eclipse.xsd.XSDPackage;
+import org.eclipse.xsd.XSDSchema;
+import org.eclipse.xsd.util.XSDResourceFactoryImpl;
+import org.eclipse.xsd.util.XSDUtil;
+
+/**
+ * A set of utilities to parse XML schemas and accounting for file imports.
+ * <p>
+ * This class can be used with {@link XSDUtil}.
+ * </p>
+ *
+ * @author Vincent Zurczak - EBM WebSourcing
+ */
+public class XmlSchemaParser {
+
+ /**
+ * Loads a XML schema.
+ * @param emfUri an EMF URI
+ * @param resourceSet a resource set
+ * @return an instance of {@link XSDSchema}
+ * <p>
+ * This object already supports inclusions, which means there is no need to
+ * get the imports and parse them.
+ * </p>
+ */
+ public static XSDSchema loadXmlSchema( URI emfUri, ResourceSet resourceSet ) {
+ Resource resource = resourceSet.getResource( emfUri, true );
+ return (XSDSchema) resource.getContents().iterator().next();
+ }
+
+
+ /**
+ * @return a resource set to parse XML schemas
+ */
+ public static ResourceSet createBasicResourceSetForXmlSchema() {
+
+ ResourceSet resourceSet = new ResourceSetImpl();
+ resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put( "xml", new XMLResourceFactoryImpl());
+ resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put( "xsd", new XSDResourceFactoryImpl());
+ resourceSet.getPackageRegistry().put( XSDPackage.eNS_URI, XSDPackage.eINSTANCE );
+
+ return resourceSet;
+ }
+}
diff --git a/plugins/org.eclipse.bpel.common.wsdl/src/org/eclipse/bpel/common/wsdl/wizards/UriResourceImportWizardPage.java b/plugins/org.eclipse.bpel.common.wsdl/src/org/eclipse/bpel/common/wsdl/wizards/UriResourceImportWizardPage.java
new file mode 100644
index 0000000..eac2378
--- /dev/null
+++ b/plugins/org.eclipse.bpel.common.wsdl/src/org/eclipse/bpel/common/wsdl/wizards/UriResourceImportWizardPage.java
@@ -0,0 +1,348 @@
+/****************************************************************************
+ *
+ * Copyright (c) 2010-2011, EBM WebSourcing
+ *
+ * This source code is available under agreement available at
+ * http://www.petalslink.com/legal/licenses/petals-studio
+ *
+ * You should have received a copy of the agreement along with this program.
+ * If not, write to EBM WebSourcing (4, rue Amelie - 31200 Toulouse, France).
+ *
+ *****************************************************************************/
+
+package org.eclipse.bpel.common.wsdl.wizards;
+
+import java.io.File;
+import java.net.URI;
+import java.util.ArrayList;
+
+import org.eclipse.bpel.common.wsdl.helpers.UriAndUrlHelper;
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.PlatformObject;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.FileDialog;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.model.WorkbenchContentProvider;
+import org.eclipse.ui.model.WorkbenchLabelProvider;
+
+/**
+ * A wizard page to import a resource in the workspace.
+ * @author Vincent Zurczak - EBM WebSourcing
+ * FIXME: is there an existing page we could reuse?
+ */
+public class UriResourceImportWizardPage extends WizardPage {
+
+ private URI uri;
+ private IContainer outputContainer;
+ private boolean complete = false;
+
+ private String initialUri;
+ private final String shortName;
+ private final String[] filterNames, filterExtensions;
+
+
+ /**
+ * Constructor.
+ * @param selection
+ * @param shortName
+ * @param filterNames
+ * @param filterExtensions
+ */
+ public UriResourceImportWizardPage(
+ IStructuredSelection selection,
+ String shortName,
+ String[] filterNames,
+ String[] filterExtensions ) {
+
+ super( "Import Page" );
+ this.shortName = shortName;
+ this.filterNames = filterNames;
+ this.filterExtensions = filterExtensions;
+
+ if( ! selection.isEmpty()) {
+ Object o = selection.getFirstElement();
+ IResource res = (IResource) getAdapter( o, IResource.class );
+ if( res instanceof IContainer )
+ this.outputContainer = (IContainer) res;
+ else if( res != null )
+ this.outputContainer = res.getParent();
+ }
+ }
+
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.IDialogPage
+ * #createControl(org.eclipse.swt.widgets.Composite)
+ */
+ @Override
+ public void createControl( Composite parent ) {
+
+ Composite container = new Composite( parent, SWT.NONE );
+ GridLayout layout = new GridLayout( 2, false );
+ container.setLayout( layout );
+ container.setLayoutData( new GridData( GridData.FILL_BOTH ));
+
+
+ // WSDL field
+ Label l = new Label( container, SWT.NONE );
+ l.setText( this.shortName + " URI:" );
+
+ GridData layoutData = new GridData();
+ layoutData.verticalIndent = 6;
+ layoutData.horizontalSpan = 2;
+ l.setLayoutData( layoutData );
+
+ final Text text = new Text( container, SWT.BORDER | SWT.SINGLE );
+ text.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ));
+ text.addModifyListener( new ModifyListener () {
+
+ @Override
+ public void modifyText( ModifyEvent e ) {
+ String uri = text.getText();
+ if( uri.trim().length() == 0 )
+ return;
+
+ try {
+ UriResourceImportWizardPage.this.uri = UriAndUrlHelper.urlToUri( uri );
+
+ } catch( Exception e1 ) {
+ UriResourceImportWizardPage.this.uri = null;
+ }
+
+ validate();
+ }
+ });
+
+ if( this.initialUri != null )
+ text.setText( this.initialUri );
+
+ Button b = new Button( container, SWT.PUSH );
+ b.setText( "Browse..." );
+ b.addSelectionListener( new SelectionAdapter () {
+ @Override
+ public void widgetDefaultSelected( SelectionEvent e ) {
+ widgetSelected( e );
+ }
+
+ @Override
+ public void widgetSelected( SelectionEvent e ) {
+
+ FileDialog dlg = new FileDialog( text.getShell(), SWT.SINGLE );
+ dlg.setFilterNames( UriResourceImportWizardPage.this.filterNames );
+ dlg.setFilterExtensions( UriResourceImportWizardPage.this.filterExtensions );
+ String path = dlg.open();
+
+ if( path != null ) {
+ String uri = new File( path ).toURI().toString();
+ text.setText( uri );
+ text.setSelection( uri.length());
+ text.setFocus();
+ }
+ }
+ });
+
+
+ // Container selection
+ l = new Label( container, SWT.NONE );
+ l.setText( "Select the container in which the " + this.shortName + " will be imported." );
+
+ layoutData = new GridData();
+ layoutData.verticalIndent = 10;
+ layoutData.horizontalSpan = 2;
+ l.setLayoutData( layoutData );
+
+ TreeViewer viewer = new TreeViewer( container, SWT.SINGLE | SWT.V_SCROLL | SWT.V_SCROLL | SWT.BORDER );
+ layoutData = new GridData( GridData.FILL_BOTH );
+ layoutData.heightHint = 200;
+ layoutData.horizontalSpan = 2;
+ viewer.getTree().setLayoutData( layoutData );
+ viewer.setLabelProvider( new WorkbenchLabelProvider ());
+
+ viewer.setContentProvider( new WorkbenchContentProvider () {
+ @Override
+ public Object[] getChildren( Object o ) {
+
+ if( o instanceof IContainer ) {
+ IResource[] members;
+ try {
+ members = ((IContainer) o).members();
+ } catch( Exception e ) {
+ return new Object[ 0 ];
+ }
+
+ ArrayList<IResource> results = new ArrayList<IResource> ();
+ for( IResource member : members ) {
+ if( member instanceof IContainer )
+ results.add( member);
+ }
+
+ return results.toArray();
+ }
+
+ return new Object[ 0 ];
+ }
+ });
+
+
+ // Set page input
+ IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+ viewer.setInput( root );
+ if( this.outputContainer != null ) {
+ viewer.setSelection( new StructuredSelection( this.outputContainer ), true );
+ viewer.expandToLevel( this.outputContainer, 1 );
+ viewer.reveal( this.outputContainer.getProject());
+ }
+
+ viewer.addSelectionChangedListener( new ISelectionChangedListener () {
+ @Override
+ public void selectionChanged( SelectionChangedEvent event ) {
+
+ IStructuredSelection s = (IStructuredSelection) event.getSelection();
+ if( !s.isEmpty())
+ UriResourceImportWizardPage.this.outputContainer = (IContainer) s.getFirstElement();
+ else
+ UriResourceImportWizardPage.this.outputContainer = null;
+ validate();
+ }
+ });
+
+ text.setFocus();
+ setControl( container );
+ }
+
+
+ /**
+ * Validates the page entries.
+ */
+ private void validate() {
+
+ if( this.uri == null ) {
+ setErrorMessage( "The " + this.shortName + "'s URI is invalid." );
+ setPageComplete( false );
+ return;
+ }
+
+ if( "file".equals( this.uri.getScheme())
+ && ! new File( this.uri ).exists()) {
+ setErrorMessage( "This URI points to a file that does not exist." );
+ setPageComplete( false );
+ return;
+ }
+
+ if( this.outputContainer == null ) {
+ setErrorMessage( "You must select the destination container." );
+ setPageComplete( false );
+ return;
+ }
+
+ setErrorMessage( null );
+ setPageComplete( true );
+ }
+
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.wizard.WizardPage
+ * #isPageComplete()
+ */
+ @Override
+ public boolean isPageComplete() {
+ return this.complete;
+ }
+
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.wizard.WizardPage
+ * #setPageComplete(boolean)
+ */
+ @Override
+ public void setPageComplete( boolean complete ) {
+ this.complete = complete;
+ super.setPageComplete( complete );
+ }
+
+
+ /**
+ * @return the outputContainer
+ */
+ public IContainer getOutputContainer() {
+ return this.outputContainer;
+ }
+
+
+ /**
+ * @return the uri
+ */
+ public URI getUriToImport() {
+ return this.uri;
+ }
+
+
+ /**
+ * @param initialUri the initial URI to set
+ */
+ public void setInitialUri( String initialUri ) {
+ this.initialUri = initialUri;
+ }
+
+
+ /**
+ * Gets the appropriate adapter.
+ * @param sourceObject
+ * @param adapterType
+ * @return
+ */
+ public static Object getAdapter( Object sourceObject, Class<?> adapterType ) {
+
+ Assert.isNotNull(adapterType);
+ if (sourceObject == null) {
+ return null;
+ }
+ if (adapterType.isInstance(sourceObject)) {
+ return sourceObject;
+ }
+
+ if (sourceObject instanceof IAdaptable) {
+ IAdaptable adaptable = (IAdaptable) sourceObject;
+
+ Object result = adaptable.getAdapter(adapterType);
+ if (result != null) {
+ // Sanity-check
+ Assert.isTrue(adapterType.isInstance(result));
+ return result;
+ }
+ }
+
+ if (!(sourceObject instanceof PlatformObject)) {
+ Object result = Platform.getAdapterManager().getAdapter(sourceObject, adapterType);
+ if (result != null) {
+ return result;
+ }
+ }
+
+ return null;
+ }
+}
diff --git a/plugins/org.eclipse.bpel.common.wsdl/src/org/eclipse/bpel/common/wsdl/wizards/WsdlImportWizard.java b/plugins/org.eclipse.bpel.common.wsdl/src/org/eclipse/bpel/common/wsdl/wizards/WsdlImportWizard.java
new file mode 100644
index 0000000..631a9a0
--- /dev/null
+++ b/plugins/org.eclipse.bpel.common.wsdl/src/org/eclipse/bpel/common/wsdl/wizards/WsdlImportWizard.java
@@ -0,0 +1,194 @@
+/****************************************************************************
+ *
+ * Copyright (c) 2010-2011, EBM WebSourcing
+ *
+ * This source code is available under agreement available at
+ * http://www.petalslink.com/legal/licenses/petals-studio
+ *
+ * You should have received a copy of the agreement along with this program.
+ * If not, write to EBM WebSourcing (4, rue Amelie - 31200 Toulouse, France).
+ *
+ *****************************************************************************/
+
+package org.eclipse.bpel.common.wsdl.wizards;
+
+import java.io.File;
+import java.lang.reflect.InvocationTargetException;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.bpel.common.wsdl.SoaWsdlCommonPlugin;
+import org.eclipse.bpel.common.wsdl.importhelpers.WsdlImportHelper;
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.ui.IImportWizard;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.actions.WorkspaceModifyOperation;
+import org.eclipse.ui.wizards.newresource.BasicNewFileResourceWizard;
+
+/**
+ * A wizard to import a WSDL file in a project or a project's directory.
+ * @author Vincent Zurczak - EBM WebSourcing
+ */
+public class WsdlImportWizard extends Wizard implements IImportWizard {
+
+ private UriResourceImportWizardPage page;
+ private IStructuredSelection selection;
+ private IWorkbenchWindow window;
+
+ private String initialWsdlUri;
+ private IContainer initialContainer;
+ private File wsdlFileAfterImport;
+
+
+ /**
+ * Constructor.
+ */
+ public WsdlImportWizard() {
+ super();
+ setNeedsProgressMonitor( true );
+ setWindowTitle( "WSDL Import" );
+ }
+
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.wizard.Wizard
+ * #addPages()
+ */
+ @Override
+ public void addPages() {
+
+ if( this.initialContainer != null )
+ this.selection = new StructuredSelection( this.initialContainer );
+
+ this.page = new UriResourceImportWizardPage(
+ this.selection, "WSDL",
+ new String[] { "WSDL (*.wsdl)" },
+ new String[] { "*.wsdl" });
+
+ this.page.setTitle( "WSDL Import" );
+ this.page.setDescription( "Import a WSDL and all its dependencies." );
+ this.page.setInitialUri( this.initialWsdlUri );
+ addPage( this.page );
+ }
+
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.wizard.Wizard
+ * #performFinish()
+ */
+ @Override
+ public boolean performFinish() {
+
+ // Define the wizard completion process
+ final Map<String,File> uriToFile = new HashMap<String,File> ();
+ WorkspaceModifyOperation op = new WorkspaceModifyOperation() {
+ @Override
+ protected void execute( IProgressMonitor monitor )
+ throws CoreException, InvocationTargetException, InterruptedException {
+ try {
+ String wsdlUri = WsdlImportWizard.this.page.getUriToImport().toString();
+ monitor.beginTask( "Importing " + wsdlUri, IProgressMonitor.UNKNOWN );
+ File outputContainer = WsdlImportWizard.this.page.getOutputContainer().getLocation().toFile();
+ uriToFile.putAll( new WsdlImportHelper().importWsdlOrXsdAndDependencies( outputContainer, wsdlUri ));
+
+ } catch( Exception e ) {
+ throw new InvocationTargetException( e );
+
+ } finally {
+ monitor.done();
+ }
+ }
+ };
+
+ // Run the operation
+ IContainer outputContainer = this.page.getOutputContainer();
+ try {
+ getContainer().run( true, false, op );
+ try {
+ outputContainer.refreshLocal( IResource.DEPTH_INFINITE, new NullProgressMonitor ());
+ } catch( CoreException e ) {
+ // nothing
+ }
+
+ this.wsdlFileAfterImport = uriToFile.get( this.page.getUriToImport().toString());
+ if( this.wsdlFileAfterImport != null ) {
+ IPath path = new Path( this.wsdlFileAfterImport.getAbsolutePath());
+ IFile f = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation( path );
+ if( f != null )
+ BasicNewFileResourceWizard.selectAndReveal( f, this.window );
+ }
+
+ } catch( InterruptedException e ) {
+
+ // Delete imported resources
+ for( File f : uriToFile.values()) {
+ if( ! f.delete())
+ SoaWsdlCommonPlugin.log( "Could not delete " + f.getAbsolutePath() + ".", IStatus.WARNING );
+ }
+
+ try {
+ outputContainer.refreshLocal( IResource.DEPTH_INFINITE, new NullProgressMonitor ());
+ } catch( CoreException ee ) {
+ // nothing
+ }
+
+ } catch( InvocationTargetException e ) {
+ SoaWsdlCommonPlugin.log( "A WSDL file could not be imported (" + this.page.getUriToImport().toString() + ".", IStatus.ERROR );
+ MessageDialog.openError( getShell(), "Import Error", "The WSDL file could not be imported." );
+ }
+
+ return true;
+ }
+
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.IWorkbenchWizard
+ * #init(org.eclipse.ui.IWorkbench, org.eclipse.jface.viewers.IStructuredSelection)
+ */
+ @Override
+ public void init( IWorkbench workbench, IStructuredSelection selection ) {
+ this.selection = selection;
+ this.window = workbench.getActiveWorkbenchWindow();
+ }
+
+
+ /**
+ * @param initialWsdlUri the initialWsdlUri to set
+ */
+ public void setInitialWsdlUri( String initialWsdlUri ) {
+ this.initialWsdlUri = initialWsdlUri;
+ }
+
+
+ /**
+ * @param initialContainer the initialContainer to set
+ */
+ public void setInitialContainer( IContainer initialContainer ) {
+ this.initialContainer = initialContainer;
+ }
+
+
+ /**
+ * @return the wsdlFileAfterImport
+ */
+ public File getWsdlFileAfterImport() {
+ return this.wsdlFileAfterImport;
+ }
+}
diff --git a/plugins/org.eclipse.bpel.model/src/org/eclipse/bpel/model/resource/BPELWriter.java b/plugins/org.eclipse.bpel.model/src/org/eclipse/bpel/model/resource/BPELWriter.java
index b4026ae..211af77 100644
--- a/plugins/org.eclipse.bpel.model/src/org/eclipse/bpel/model/resource/BPELWriter.java
+++ b/plugins/org.eclipse.bpel.model/src/org/eclipse/bpel/model/resource/BPELWriter.java
@@ -29,6 +29,7 @@
import org.apache.xml.serialize.XMLSerializer;
import org.eclipse.bpel.model.Activity;
import org.eclipse.bpel.model.Assign;
+import org.eclipse.bpel.model.BPELExtensibleElement;
import org.eclipse.bpel.model.BPELFactory;
import org.eclipse.bpel.model.BPELPackage;
import org.eclipse.bpel.model.Branches;
@@ -51,7 +52,6 @@
import org.eclipse.bpel.model.EventHandler;
import org.eclipse.bpel.model.Exit;
import org.eclipse.bpel.model.Expression;
-import org.eclipse.bpel.model.BPELExtensibleElement;
import org.eclipse.bpel.model.Extension;
import org.eclipse.bpel.model.ExtensionActivity;
import org.eclipse.bpel.model.Extensions;
@@ -139,13 +139,21 @@
import org.w3c.dom.Text;
/**
- * BPELWriter is responsible for serializing the BPEL EMF model to an output
- * stream.
+ * BPELWriter is responsible for serializing the BPEL EMF model to an output stream.
*/
-
@SuppressWarnings("nls")
public class BPELWriter {
+ /**
+ * Prevents the BPEL writer from searching and adding automatically import declarations.
+ * <p>
+ * This option was added because the BPEL writer performs some actions that are
+ * not natural with a pure EMF approach. Using this option in the EMF serialization
+ * allows to by-pass these actions for the automatic resolution of imports.
+ * </p>
+ */
+ public static final String SKIP_AUTO_IMPORT = "bpel.skip.auto.import";
+
static final String EMPTY_STRING = ""; //$NON-NLS-1$
private Document document = null;
@@ -155,7 +163,7 @@
private List<IExtensibilityElementListHandler> extensibilityElementListHandlers = null;
protected BPELPackage bpelPackage = null;
- private BPELExtensionRegistry extensionRegistry = BPELExtensionRegistry
+ private final BPELExtensionRegistry extensionRegistry = BPELExtensionRegistry
.getInstance();
/**
@@ -167,20 +175,20 @@
Process fProcessContext;
// Map of resource URIs to namespaces
- private Map<String, String> fResourceNamespaceMap;
+ private final Map<String, String> fResourceNamespaceMap;
/**
* @param context
*/
WsdlImportsManager(Process process) {
- fProcessContext = process;
+ this.fProcessContext = process;
- fResourceNamespaceMap = new HashMap<String, String>();
+ this.fResourceNamespaceMap = new HashMap<String, String>();
// For each existing import in the process, add it to the namespace
// map.
- for (Object next : fProcessContext.getImports()) {
+ for (Object next : this.fProcessContext.getImports()) {
Import imp = (org.eclipse.bpel.model.Import) next;
if (imp.getLocation() == null) {
System.err.println("Import location is unexpectedly null: "
@@ -190,7 +198,7 @@
String importPath = locationURI.resolve(
getResource().getURI()).toString();
- fResourceNamespaceMap.put(importPath, imp.getNamespace());
+ this.fResourceNamespaceMap.put(importPath, imp.getNamespace());
}
}
}
@@ -199,7 +207,7 @@
* Ensure that there exists an import mapping the given namespace to the
* given resource. If the import doesn't exist in our map, add it to the
* map and create a new Import in the process.
- *
+ *
* @param resource
* @param namespace
*/
@@ -214,7 +222,7 @@
String key = resource.getURI().toString();
- if (fResourceNamespaceMap.containsKey(key)) {
+ if (this.fResourceNamespaceMap.containsKey(key)) {
return;
}
// second check to ensure the calculated path is not empty
@@ -235,10 +243,10 @@
.setImportType(XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001);
}
- fProcessContext.getImports().add(_import);
+ this.fProcessContext.getImports().add(_import);
// Add it to our namespace map for easy reference
- fResourceNamespaceMap.put(key, namespace);
+ this.fResourceNamespaceMap.put(key, namespace);
}
}
@@ -269,18 +277,18 @@
/**
* Return the resource used in this writer.
- *
+ *
* @return the resource used in this writer.
*/
public BPELResource getResource() {
- return fBPELResource;
+ return this.fBPELResource;
}
/**
* Convert the BPEL model to an XML DOM model and then write the DOM model
* to the output stream.
- *
+ *
* @see org.eclipse.emf.ecore.resource.impl.ResourceImpl#doSave(OutputStream,
* Map)
*/
@@ -299,32 +307,36 @@
documentBuilderFactory.setValidating(false);
DocumentBuilder builder = documentBuilderFactory
.newDocumentBuilder();
- document = builder.newDocument();
+ this.document = builder.newDocument();
// Transform the EMF model to the DOM document.
- bpelPackage = BPELPackage.eINSTANCE;
+ this.bpelPackage = BPELPackage.eINSTANCE;
- fBPELResource = resource;
+ this.fBPELResource = resource;
Process process = resource.getProcess();
// bpelNamespacePrefixManager = new NamespacePrefixManager( resource
// );
- wsdlNamespacePrefixManager = new WsdlImportsManager(process);
+ this.wsdlNamespacePrefixManager = new WsdlImportsManager(process);
- walkExternalReferences();
+ // VZ: do not force auto imports
+ Boolean skipAutoImport = (Boolean) args.get( SKIP_AUTO_IMPORT );
+ if( skipAutoImport == null || ! skipAutoImport )
+ walkExternalReferences();
+ // VZ
- document = resource2XML(resource);
+ this.document = resource2XML(resource);
// Transform the DOM document to its serialized form.
- OutputFormat fmt = new OutputFormat(document);
+ OutputFormat fmt = new OutputFormat(this.document);
fmt.setIndenting(true);
fmt.setIndent(4);
XMLSerializer serializer = new XMLSerializer(out, fmt);
- serializer.serialize(document);
+ serializer.serialize(this.document);
// The code below does not indent, due to bug in JDK 1.5. Read it
// here.
@@ -335,10 +347,10 @@
// TransformerFactory.newInstance();
// Transformer transformer = transformerFactory.newTransformer();
//
- //
+ //
// transformer.setOutputProperty(OutputKeys.INDENT, "yes");
// transformer.setOutputProperty(OutputKeys.METHOD, "xml");
- //
+ //
// // Unless a width is set, there will be only line breaks but no
// indentation.
// // The IBM JDK and the Sun JDK don't agree on the property name,
@@ -364,10 +376,10 @@
/**
* Convert the BPEL model to an XML DOM model and then write the DOM model
* to the output stream.
- *
+ *
* @param eObj
* @return
- *
+ *
* @see org.eclipse.emf.ecore.resource.impl.ResourceImpl#doSave(OutputStream,
* Map)
*/
@@ -388,25 +400,25 @@
} catch (Exception ex) {
return EMPTY_STRING;
}
- document = builder.newDocument();
+ this.document = builder.newDocument();
// Transform the EMF model to the DOM document.
- bpelPackage = BPELPackage.eINSTANCE;
+ this.bpelPackage = BPELPackage.eINSTANCE;
// bpelNamespacePrefixManager = new NamespacePrefixManager(
// getResource() );
if (eObj instanceof Process) {
- wsdlNamespacePrefixManager = new WsdlImportsManager((Process) eObj);
+ this.wsdlNamespacePrefixManager = new WsdlImportsManager((Process) eObj);
} else {
- wsdlNamespacePrefixManager = null;
+ this.wsdlNamespacePrefixManager = null;
}
anyBPELObject2xml(eObj);
// Transform the DOM document to its serialized form.
- OutputFormat fmt = new OutputFormat(document);
+ OutputFormat fmt = new OutputFormat(this.document);
fmt.setIndenting(true);
fmt.setIndent(4);
fmt.setOmitDocumentType(true);
@@ -416,9 +428,9 @@
XMLSerializer serializer = new XMLSerializer(out, fmt);
try {
- serializer.serialize(document);
+ serializer.serialize(this.document);
} catch (Exception ex) {
- //
+ //
}
return out.toString();
@@ -427,10 +439,10 @@
protected Document anyBPELObject2xml(EObject eObj) {
Element element = anyObject2xml(eObj);
- document.appendChild(element);
+ this.document.appendChild(element);
serializePrefixes(eObj, element);
- return document;
+ return this.document;
}
protected Element anyObject2xml(EObject eObj) {
@@ -483,9 +495,9 @@
protected Document resource2XML(BPELResource resource) {
Process process = resource.getProcess();
Element procElement = process2XML(process);
- document.appendChild(procElement);
+ this.document.appendChild(procElement);
serializePrefixes(process, procElement);
- return document;
+ return this.document;
}
protected Element process2XML(Process process) {
@@ -514,7 +526,7 @@
if (process.isSetAbstractProcessProfile())
processElement.setAttribute("abstractProcessProfile", process
.getAbstractProcessProfile());
-
+
for (Object next : process.getImports()) {
processElement
@@ -563,17 +575,16 @@
Map<?, ?> crossReferences = EcoreUtil.ExternalCrossReferencer
.find(getResource());
- for (Iterator<?> externalRefIt = crossReferences.keySet().iterator(); externalRefIt
- .hasNext();) {
- EObject externalObject = (EObject) externalRefIt.next();
- String namespace = getNamespace(externalObject);
- if (XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001.equals(namespace)) {
- addNewRootPrefix("xsd", namespace);
- } else if (namespace != null && externalObject.eResource() != null) {
- wsdlNamespacePrefixManager.ensureImported(externalObject
- .eResource(), namespace);
- }
- }
+ for (Object name : crossReferences.keySet()) {
+EObject externalObject = (EObject) name;
+String namespace = getNamespace(externalObject);
+if (XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001.equals(namespace)) {
+ addNewRootPrefix("xsd", namespace);
+} else if (namespace != null && externalObject.eResource() != null) {
+ this.wsdlNamespacePrefixManager.ensureImported(externalObject
+ .eResource(), namespace);
+}
+}
}
protected QName getQName(EObject object) {
@@ -1045,12 +1056,12 @@
// TODO: For backwards compatibility with 1.1 we should serialize
// OnMessages here.
- for (Iterator<?> it = eventHandler.getEvents().iterator(); it.hasNext();) {
- OnEvent onEvent = (OnEvent) it.next();
+ for (Object name : eventHandler.getEvents()) {
+ OnEvent onEvent = (OnEvent) name;
eventHandlerElement.appendChild(onEvent2XML(onEvent));
}
- for (Iterator<?> it = eventHandler.getAlarm().iterator(); it.hasNext();) {
- OnAlarm onAlarm = (OnAlarm) it.next();
+ for (Object name : eventHandler.getAlarm()) {
+ OnAlarm onAlarm = (OnAlarm) name;
eventHandlerElement.appendChild(onAlarm2XML(onAlarm));
}
// serialize local namespace prefixes to XML
@@ -1212,11 +1223,11 @@
Element activityElement = createBPELElement("opaqueActivity");
//Set Namespace to Abstract Process
- INamespaceMap<String, String> nsMap = BPELUtils.getNamespaceMap(fBPELResource.getProcess());
+ INamespaceMap<String, String> nsMap = BPELUtils.getNamespaceMap(this.fBPELResource.getProcess());
- if (fBPELResource.getOptionUseNSPrefix()) {
+ if (this.fBPELResource.getOptionUseNSPrefix()) {
nsMap.remove("");
- List<String> prefix = nsMap.getReverse(fBPELResource.getNamespaceURI());
+ List<String> prefix = nsMap.getReverse(this.fBPELResource.getNamespaceURI());
if (prefix.isEmpty()){
nsMap.put(BPELConstants.PREFIX, BPELConstants.NAMESPACE_ABSTRACT_2007);
} else {
@@ -1226,10 +1237,10 @@
} else {
nsMap.put("", BPELConstants.NAMESPACE_ABSTRACT_2007);
}
-
- fBPELResource.setNamespaceURI(BPELConstants.NAMESPACE_ABSTRACT_2007);
-
- Process process = fBPELResource.getProcess();
+
+ this.fBPELResource.setNamespaceURI(BPELConstants.NAMESPACE_ABSTRACT_2007);
+
+ Process process = this.fBPELResource.getProcess();
//Set Default Abstract Process Profile
//TODO: Let user decide whether to use a profile
if (!process.isSetAbstractProcessProfile()){
@@ -1331,11 +1342,11 @@
String localName = activity.eClass().getName();
String namespace = activity.eClass().getEPackage().getNsURI();
QName qName = new QName(namespace, localName);
- BPELActivitySerializer serializer = extensionRegistry
+ BPELActivitySerializer serializer = this.extensionRegistry
.getActivitySerializer(qName);
DocumentFragment fragment = null;
if (serializer != null) {
- fragment = document.createDocumentFragment();
+ fragment = this.document.createDocumentFragment();
serializer.marshall(qName, activity, fragment, getProcess(), this);
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=335458
// Only append Element nodes generated by the serializer
@@ -1470,8 +1481,8 @@
List<?> copies = activity.getCopy();
if (!copies.isEmpty()) {
- for (Iterator<?> i = copies.iterator(); i.hasNext();) {
- Copy copy = (Copy) i.next();
+ for (Object name : copies) {
+ Copy copy = (Copy) name;
activityElement.appendChild(copy2XML(copy));
}
}
@@ -1564,7 +1575,7 @@
DOMUtil.copyInto(child, literal);
}
} else {
- CDATASection cdata = BPELUtils.createCDATASection(document,
+ CDATASection cdata = BPELUtils.createCDATASection(this.document,
from.getLiteral());
fromElement.appendChild(cdata);
}
@@ -1583,7 +1594,7 @@
.getExpressionLanguage());
}
if (expression.getBody() != null) {
- CDATASection cdata = BPELUtils.createCDATASection(document,
+ CDATASection cdata = BPELUtils.createCDATASection(this.document,
(String) expression.getBody());
fromElement.appendChild(cdata);
}
@@ -1623,7 +1634,7 @@
BPELExtensionSerializer serializer = null;
QName qname = extensibilityElement.getElementType();
try {
- serializer = (BPELExtensionSerializer) extensionRegistry
+ serializer = (BPELExtensionSerializer) this.extensionRegistry
.querySerializer(BPELExtensibleElement.class, qname);
} catch (WSDLException e) {
}
@@ -1632,11 +1643,11 @@
// Deserialize the DOM element and add the new Extensibility
// element to the parent
// BPELExtensibleElement
- DocumentFragment fragment = document.createDocumentFragment();
+ DocumentFragment fragment = this.document.createDocumentFragment();
try {
serializer.marshall(BPELExtensibleElement.class, qname,
extensibilityElement, fragment, getProcess(),
- extensionRegistry, this);
+ this.extensionRegistry, this);
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=335458
Element child = getFirstChildElement(fragment);
return child;
@@ -1645,18 +1656,18 @@
}
}
} else if (serviceRef.getValue() != null) {
- ServiceReferenceSerializer serializer = extensionRegistry
+ ServiceReferenceSerializer serializer = this.extensionRegistry
.getServiceReferenceSerializer(serviceRef
.getReferenceScheme());
if (serializer != null) {
- DocumentFragment fragment = document.createDocumentFragment();
+ DocumentFragment fragment = this.document.createDocumentFragment();
serializer.marshall(value, fragment, getProcess(), serviceRef
.eContainer(), this);
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=335458
Element child = getFirstChildElement(fragment);
return child;
} else {
- CDATASection cdata = BPELUtils.createCDATASection(document,
+ CDATASection cdata = BPELUtils.createCDATASection(this.document,
serviceRef.getValue().toString());
return cdata;
}
@@ -1671,7 +1682,7 @@
.setAttribute("queryLanguage", query.getQueryLanguage());
}
if (query.getValue() != null) {
- CDATASection cdata = BPELUtils.createCDATASection(document, query
+ CDATASection cdata = BPELUtils.createCDATASection(this.document, query
.getValue());
queryElement.appendChild(cdata);
}
@@ -1708,7 +1719,7 @@
.getExpressionLanguage());
}
if (expression.getBody() != null) {
- CDATASection cdata = BPELUtils.createCDATASection(document,
+ CDATASection cdata = BPELUtils.createCDATASection(this.document,
(String) expression.getBody());
toElement.appendChild(cdata);
}
@@ -1942,7 +1953,7 @@
expressionElement.appendChild(child);
}
} else {
- CDATASection cdata = BPELUtils.createCDATASection(document,
+ CDATASection cdata = BPELUtils.createCDATASection(this.document,
expression.getBody().toString());
expressionElement.appendChild(cdata);
}
@@ -2254,26 +2265,25 @@
// order they appear.
List<org.eclipse.wst.wsdl.ExtensibleElement> extensibilityElements;
if (Platform.isRunning()) {
- if (extensibilityElementListHandlers == null) {
- extensibilityElementListHandlers = ExtensionFactory.INSTANCE
+ if (this.extensibilityElementListHandlers == null) {
+ this.extensibilityElementListHandlers = ExtensionFactory.INSTANCE
.createHandlers(ExtensionFactory.ID_EXTENSION_REORDERING);
}
extensibilityElements = BPELUtils.reorderExtensibilityList(
- extensibilityElementListHandlers, extensibleElement);
+ this.extensibilityElementListHandlers, extensibleElement);
} else {
extensibilityElements = extensibleElement.getExtensibilityElements();
}
// Loop through the extensibility elements
- for (Iterator<?> i = extensibilityElements.iterator(); i.hasNext();) {
- ExtensibilityElement extensibilityElement = (ExtensibilityElement) i
- .next();
+ for (Object name : extensibilityElements) {
+ ExtensibilityElement extensibilityElement = (ExtensibilityElement) name;
// Lookup a serializer for the extensibility element
BPELExtensionSerializer serializer = null;
QName qname = extensibilityElement.getElementType();
try {
- serializer = (BPELExtensionSerializer) extensionRegistry
+ serializer = (BPELExtensionSerializer) this.extensionRegistry
.querySerializer(BPELExtensibleElement.class, qname);
} catch (WSDLException e) {
// TODO: Exception handling
@@ -2281,14 +2291,14 @@
if (serializer != null) {
// Create a temp document fragment for the serializer
- DocumentFragment fragment = document.createDocumentFragment();
+ DocumentFragment fragment = this.document.createDocumentFragment();
// Serialize the extensibility element into the parent DOM
// element
try {
serializer.marshall(BPELExtensibleElement.class, qname,
extensibilityElement, fragment, getProcess(),
- extensionRegistry, this);
+ this.extensionRegistry, this);
} catch (WSDLException e) {
throw new WrappedException(e);
}
@@ -2343,7 +2353,7 @@
}
/**
- * Get process from the resource
+ * Get process from the resource
* @return the Process
*/
private Process getProcess() {
@@ -2359,7 +2369,7 @@
BPELExtensionSerializer serializer = null;
QName qname = extensibilityElement.getElementType();
try {
- serializer = (BPELExtensionSerializer) extensionRegistry
+ serializer = (BPELExtensionSerializer) this.extensionRegistry
.querySerializer(BPELExtensibleElement.class, qname);
} catch (WSDLException e) {
return null;
@@ -2368,12 +2378,12 @@
// Deserialize the DOM element and add the new Extensibility element to
// the parent
// BPELExtensibleElement
- DocumentFragment fragment = document.createDocumentFragment();
+ DocumentFragment fragment = this.document.createDocumentFragment();
try {
serializer
.marshall(BPELExtensibleElement.class, qname,
extensibilityElement, fragment, getProcess(),
- extensionRegistry, this);
+ this.extensionRegistry, this);
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=335458
Element child = getFirstChildElement(fragment);
return child;
@@ -2397,16 +2407,16 @@
List<String> prefixes = BPELUtils.getNamespaceMap(
getProcess()).getReverse(namespaceURI);
if (!prefixes.isEmpty() && !prefixes.get(0).equals("")) {
- return document.createElementNS(namespaceURI, prefixes.get(0)
+ return this.document.createElementNS(namespaceURI, prefixes.get(0)
+ ":" + tagName);
}
}
- return document.createElement(tagName);
+ return this.document.createElement(tagName);
}
/**
- *
+ *
* @return the namespace prefix manager.
*/
@@ -2489,11 +2499,11 @@
while (child != null && !(child instanceof Element)) {
child = child.getNextSibling();
}
-
+
// We are out of the loop: either child is null, or it is an element
if( child != null )
return (Element) child;
-
+
throw new IllegalArgumentException("Document Fragment does not contain any Elements");
}
}
diff --git a/plugins/org.eclipse.bpel.model/src/org/eclipse/bpel/model/util/WSDLUtil.java b/plugins/org.eclipse.bpel.model/src/org/eclipse/bpel/model/util/WSDLUtil.java
index 476cf50..06b02e9 100644
--- a/plugins/org.eclipse.bpel.model/src/org/eclipse/bpel/model/util/WSDLUtil.java
+++ b/plugins/org.eclipse.bpel.model/src/org/eclipse/bpel/model/util/WSDLUtil.java
@@ -42,38 +42,38 @@
/**
- * WSDLUtil supplies resolution (lookup) of various things that are useful in the BPEL
- * world.
+ * WSDLUtil supplies resolution (lookup) of various things that are useful in the BPEL
+ * world.
*
*/
public class WSDLUtil
-{
+{
/** The WSDL Message attribute/name, most likely "message" */
-
+
public static final String WSDL_MESSAGE = WSDLPackage.eINSTANCE.getMessage().getName();
-
+
/** The WSDL Port Type attribute/name, most likely "portType" */
public static final String WSDL_PORT_TYPE = WSDLPackage.eINSTANCE.getPortType().getName();
-
+
/** The WSDL Operation attribute/name, most likely "operation" */
public static final String WSDL_OPERATION = WSDLPackage.eINSTANCE.getOperation().getName();
-
+
/** The WSDL Part attribute/name, most likely "part" */
public static final String WSDL_PART = WSDLPackage.eINSTANCE.getPart().getName();
-
+
/** The WSDL Service attribute/name, most likely "service" */
public static final String WSDL_SERVICE = WSDLPackage.eINSTANCE.getService().getName();
-
+
/** The XSD Type Definition attribute/name, most likely "type" */
public static final String XSD_TYPE_DEFINITION = XSDPackage.eINSTANCE.getXSDTypeDefinition().getName();
-
+
/** The XSD Element Declaration attribute/name, most likely "element" */
public static final String XSD_ELEMENT_DECLARATION = XSDPackage.eINSTANCE.getXSDElementDeclaration().getName();
-
+
/** The BPEL Partner Link Type attribute/name, most likely "partnerLinkType" */
public static final String BPEL_PARTNER_LINK_TYPE = PartnerlinktypePackage.eINSTANCE.getPartnerLinkType().getName();
-
+
/** The BPEL Role attribute/name, most likely "role" */
public static final String BPEL_ROLE = PartnerlinktypePackage.eINSTANCE.getRole().getName();
@@ -82,15 +82,15 @@
/** This should be a preference that can be easily turned on/off */
private static boolean RESOLVING_DEEPLY = true; // TODO: Preference based ?
-
-
+
+
/**
* Answer true if the type name passed is a WSDL thing.
- *
+ *
* @param typeName
* @return true if yes, false if no.
*/
-
+
public static boolean isWSDLType(String typeName)
{
return typeName == null ? false :
@@ -106,38 +106,38 @@
|| BPEL_PROPERTY.equals(typeName);
}
-
+
/**
* Set to resolve deeply.
* @param resolveDeeply
*/
-
+
public static void setResolveDeeply ( boolean resolveDeeply ) {
RESOLVING_DEEPLY = resolveDeeply;
}
-
+
/**
* Answer if resolving deeply.
* @return answer true if resolving deeply, false otherwise.
*/
-
+
public static boolean isResolvingDeeply () {
return RESOLVING_DEEPLY;
}
-
+
/**
* Resolve with the given definition the QName given.
* @param definition the definition to use.
* @param qname the QName to resolve.
- * @param name
+ * @param name
* @param refType what to resolve (that things from WSDL that we can resolve).
* @return the EMF object that the QName resolves to.
*/
-
+
public static EObject resolveWSDLReference(Definition definition, QName qname, String name, String refType)
{
EObject resolvedObject = null;
-
+
if (WSDL_PORT_TYPE.equals(refType)) {
resolvedObject = resolvePortType(definition, qname);
} else if (WSDL_MESSAGE.equals(refType)) {
@@ -161,59 +161,62 @@
} else {
System.err.println(WSDLUtil.class.getName() + ": unrecognized refType: " + refType); //$NON-NLS-1$
}
-
+
return resolvedObject;
}
-
-
-
- /**
+
+
+
+ /**
* Use Java generics to write the "finders" of various elements, so that the general code
* which does the lookups and follows imports does not need to be repeated.
- *
+ *
* @author Michal Chmielewski (michal.chmielewski@oracle.com)
* @date Feb 27, 2007
*
* @param <T> the type that we are looking up (PortType, Message, PartnerLinkType)
*/
-
+
interface Finder<S,T> {
/**
* Find the thing in the container
- *
+ *
* @param source the source where to look (definition, schema)
* @param qname the QName to lookup
* @return the resolved entity, or null
*/
T find (S source, QName qname);
}
-
-
+
+
/** Generic way of looking up port types */
static final Finder<Definition,PortType> PORT_TYPE_FINDER = new Finder<Definition, PortType>() {
+ @Override
public PortType find (Definition defn, QName qname) {
return (PortType) defn.getPortType(qname) ;
- }
+ }
};
-
+
/** Generic way of looking up messages */
static final Finder<Definition,Message> MESSAGE_FINDER = new Finder<Definition,Message> () {
- public Message find (Definition defn, QName qname) {
+ @Override
+ public Message find (Definition defn, QName qname) {
return (Message) defn.getMessage(qname);
}
};
-
+
/** Generic way of looking up partner link types */
static final Finder<Definition,PartnerLinkType> PARTNER_LINK_TYPE_FINDER = new Finder<Definition,PartnerLinkType>() {
-
- public PartnerLinkType find (Definition defn, QName qname) {
-
+
+ @Override
+ public PartnerLinkType find (Definition defn, QName qname) {
+
if (defn.getTargetNamespace() == null)
return null;
-
+
if (defn.getTargetNamespace().equals(qname.getNamespaceURI()) == false) {
return null;
- }
+ }
Iterator<?> it = defn.getExtensibilityElements().iterator();
while (it.hasNext()) {
Object e = it.next();
@@ -227,11 +230,12 @@
return null;
}
};
-
+
/** Generic way of lookup up BPEL properties */
static final Finder<Definition,Property> PROPERTY_FINDER = new Finder<Definition,Property>() {
- public Property find(Definition defn, QName qname) {
+ @Override
+ public Property find(Definition defn, QName qname) {
if (defn.getTargetNamespace().equals(qname.getNamespaceURI()) == false) {
return null;
}
@@ -244,122 +248,124 @@
return property;
}
}
- }
+ }
return null;
- }
+ }
};
-
- /** Type definition finder */
+
+ /** Type definition finder */
static private final Finder<XSDSchema,XSDTypeDefinition> TYPE_DEFINITION_FINDER = new Finder<XSDSchema,XSDTypeDefinition>() {
+ @Override
public XSDTypeDefinition find(XSDSchema schema, QName typeName) {
// Perhaps this is what we want ...
// http://www.eclipse.org/modeling/emf/faq/#dev20040602-1383194195
- //
- XSDTypeDefinition typeDef = schema.resolveTypeDefinition(typeName.getNamespaceURI(), typeName.getLocalPart());
+ //
+ XSDTypeDefinition typeDef = schema.resolveTypeDefinition(typeName.getNamespaceURI(), typeName.getLocalPart());
if (typeDef.getContainer() == null) {
return null;
}
return typeDef;
}
};
-
+
/** Element declaration finder */
static private final Finder<XSDSchema,XSDElementDeclaration> ELEMENT_DECLARATION_FINDER = new Finder<XSDSchema,XSDElementDeclaration> () {
+ @Override
public XSDElementDeclaration find(XSDSchema schema, QName qn) {
XSDElementDeclaration decl = schema.resolveElementDeclaration( qn.getNamespaceURI(), qn.getLocalPart());
-
- // TODO: (Hack)
+
+ // TODO: (Hack)
// Why has this started returning instances of XSDElementDeclrarion that are not proxies or null
// if the element declaration is missing in the schema ?
// Perhaps this is what we want: http://www.eclipse.org/modeling/emf/faq/#dev20040602-1383194195
-
+
if (decl.getContainer() == null) {
return null;
}
return decl;
}
};
-
+
/**
* Resolve the port type in the definition given.
- *
+ *
* @param definition the WSDL definition
* @param qname the QName of the portType
* @return the resolved portType, or null
*/
-
+
public static PortType resolvePortType (Definition definition, QName qname)
- {
+ {
return resolveUsingFinder ( definition, qname, PORT_TYPE_FINDER, new HashSet<Definition>() );
}
-
-
- /**
+
+
+ /**
* Resolve using finder resolves the QName in the definitions passed. The return object
* extends from EObject (so PortType, Message, PartnerLinkType, etc). The finder has the actual lookup
* code while the general code flow that deals with following the imports is shared among the lookup
* methods in this class.
- *
- * @param <T> the type
+ *
+ * @param <T> the type
* @param defn the definition to use as the lookup
* @param qname the QName to lookup
* @param finder the finder to use.
* @param seen the seen set
* @return the object to be resolved.
*/
-
+
@SuppressWarnings("restriction")
static <T extends EObject> T resolveUsingFinder ( Definition defn, QName qname, Finder<Definition,T> finder , Set<Definition> seen) {
-
+
if (seen.contains(defn)) {
return null;
}
- seen.add(defn);
-
+ seen.add(defn);
+
T result = finder.find ( defn, qname );
-
+
if (result != null || RESOLVING_DEEPLY == false) {
return result;
- }
-
+ }
+
Iterator<?> it = defn.getImports(qname.getNamespaceURI()).iterator();
while (it.hasNext() && result == null) {
ImportImpl imp = (ImportImpl) it.next();
- imp.importDefinitionOrSchema();
+ imp.importDefinitionOrSchema();
Definition importedDefinition = (Definition) imp.getDefinition();
if (importedDefinition != null) {
- result = resolveUsingFinder (importedDefinition, qname, finder, seen );
+ result = resolveUsingFinder (importedDefinition, qname, finder, seen );
}
}
return result;
}
-
-
-
+
+
+
/**
* Resolve the message name in the definitions passed.
* @param definition the definitions
* @param qname the message name
* @return the message name or null
*/
-
+
public static Message resolveMessage(Definition definition, QName qname)
- {
+ {
return resolveUsingFinder(definition, qname, MESSAGE_FINDER, new HashSet<Definition>());
}
-
-
+
+
/**
* Resolve operation within a portType. First lookup portType, then find the operation by name given.
* @param definition the definition to search
* @param portTypeQName QName of the portType to lookup operation on
* @param operationName the operation name.
- * @return the operation or null
+ * @return the operation or null
*/
-
+
public static Operation resolveOperation(Definition definition, QName portTypeQName, String operationName)
{
PortType portType = resolvePortType(definition, portTypeQName);
@@ -373,62 +379,62 @@
* @param name the name of the message part.
* @return the part, or null
*/
-
+
public static Part resolvePart(Definition definition, QName qname, String name)
- {
- return findPart( resolveMessage(definition, qname) , name );
+ {
+ return findPart( resolveMessage(definition, qname) , name );
}
-
+
/**
- * Resolve (lookup) a partner link type in the definitions given.
+ * Resolve (lookup) a partner link type in the definitions given.
* @param defn the definitions to use
* @param qname the QName to lookup
* @return the partner link type or null
*/
-
+
public static PartnerLinkType resolveBPELPartnerLinkType(Definition defn, QName qname)
{
return resolveUsingFinder(defn, qname, PARTNER_LINK_TYPE_FINDER, new HashSet<Definition>() );
}
-
+
/**
* Resolve BPEL Role on the partner link specified.
- *
+ *
* @param definition the definition to use
* @param qname QNAme of the partner link type
* @param name the name of the role on that partner link type
* @return the BPEL role, or null
*/
-
+
public static EObject resolveBPELRole(Definition definition, QName qname, String name)
{
return findRole ( resolveBPELPartnerLinkType(definition, qname) , name );
}
-
-
+
+
/**
* Lookup the BPEL property in the definition given.
- *
+ *
* @param defn the definition
* @param qname the property QName to lookup
* @return the property or null
*/
-
+
public static Property resolveBPELProperty(Definition defn, QName qname)
{
return resolveUsingFinder(defn, qname, PROPERTY_FINDER, new HashSet<Definition>());
}
-
-
-
+
+
+
private static Service resolveService(Definition definition, QName qname) {
return (Service) definition.getService(qname);
}
-
-
-
+
+
+
/**
* Common code for resolving XSDTypeDefinitions and XSDElementDeclarations
*/
@@ -436,22 +442,22 @@
static <T> T resolveXSD (Definition definition, QName qname, Finder<XSDSchema,T> finder, Set<Definition> seen )
{
T result = null;
-
+
if (seen.contains(definition)) {
return result;
}
seen.add(definition);
-
+
// Check for built-in types
// TODO Slightly inefficient to evaluate this when recursing
XSDSchema schema = null;
String namespace = qname.getNamespaceURI();
-
+
if ("".equals(namespace)) { //$NON-NLS-1$
namespace = null;
}
-
+
if (XSDConstants.isSchemaForSchemaNamespace(namespace)) {
schema = XSDSchemaImpl.getSchemaForSchema(namespace);
} else if (XSDConstants.isSchemaInstanceNamespace(namespace)) {
@@ -487,10 +493,10 @@
* Check imported schemas and definitions.
* If we are here, then result is still null
*/
-
+
// TODO: I think I need to check all imports, not just those
// matching the same namespace...
-
+
Iterator<?> it = definition.getImports(qname.getNamespaceURI()).iterator();
while (it.hasNext()) {
ImportImpl imp = (ImportImpl) it.next();
@@ -506,53 +512,51 @@
result = resolveXSD(importedDefinition, qname, finder, seen );
if (result != null) {
return result;
- }
+ }
}
}
- return result;
+ return result;
}
-
-
+
+
/**
* Resolve type definition. Basically lookup type by QName.
- *
+ *
* @param definition
* @param qname
* @return the XSDTypeDefinition found or null if it does not exist.
*/
-
+
public static XSDTypeDefinition resolveXSDTypeDefinition(Definition definition, QName qname)
- {
+ {
return resolveXSD(definition, qname ,TYPE_DEFINITION_FINDER, new HashSet<Definition>() );
}
-
+
/**
* Resolve the XSDElement declaration in this definition. Basically, lookup element declaration using the
- * QName specified in the definition indicated.
- *
+ * QName specified in the definition indicated.
+ *
* @param definition
* @param qname
- * @return the XSDElement declaration if found. null otherwise.
+ * @return the XSDElement declaration if found. null otherwise.
*/
-
+
public static XSDElementDeclaration resolveXSDElementDeclaration(Definition definition, QName qname)
- {
+ {
return resolveXSD(definition, qname, ELEMENT_DECLARATION_FINDER, new HashSet<Definition>() );
}
-
-
-
+
+
+
/**
* Find a role in the partner link type.
* @param plt the partner link type
* @param name the role name to find.
* @return the found role or null if it does not exist.
*/
-
- @SuppressWarnings("unchecked")
public static Role findRole ( PartnerLinkType plt, String name ) {
-
+
if (plt != null) {
Iterator<Role> it = plt.getRole().iterator();
while (it.hasNext()) {
@@ -564,17 +568,17 @@
}
return null;
}
-
-
+
+
/**
* Find the operation in the port type.
* @param portType the port type
* @param operationName the operation name
* @return return the operation in the port type or null
*/
-
+
@SuppressWarnings("unchecked")
- public static Operation findOperation (PortType portType, String operationName) {
+ public static Operation findOperation (PortType portType, String operationName) {
if (portType != null) {
Iterator<Operation> it = portType.getOperations().iterator();
while (it.hasNext()) {
diff --git a/plugins/org.eclipse.bpel.ui/META-INF/MANIFEST.MF b/plugins/org.eclipse.bpel.ui/META-INF/MANIFEST.MF
index a9137af..3d5c6c5 100644
--- a/plugins/org.eclipse.bpel.ui/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.bpel.ui/META-INF/MANIFEST.MF
@@ -32,7 +32,8 @@
org.eclipse.wst.common.emfworkbench.integration,
org.eclipse.jem.util,
org.eclipse.wst.common.project.facet.core,
- org.eclipse.bpel.runtimes
+ org.eclipse.bpel.runtimes,
+ org.eclipse.bpel.common.wsdl
Bundle-ActivationPolicy: lazy
Export-Package: org.eclipse.bpel.ui,
org.eclipse.bpel.ui.actions,
diff --git a/plugins/org.eclipse.bpel.ui/icons/obj16/help.gif b/plugins/org.eclipse.bpel.ui/icons/obj16/help.gif
new file mode 100644
index 0000000..ae2c4c0
--- /dev/null
+++ b/plugins/org.eclipse.bpel.ui/icons/obj16/help.gif
Binary files differ
diff --git a/plugins/org.eclipse.bpel.ui/plugin.xml b/plugins/org.eclipse.bpel.ui/plugin.xml
index d9bf9fb..c708dd3 100644
--- a/plugins/org.eclipse.bpel.ui/plugin.xml
+++ b/plugins/org.eclipse.bpel.ui/plugin.xml
@@ -15,6 +15,7 @@
class="org.eclipse.bpel.ui.BPELMultipageEditorPart"
contributorClass="org.eclipse.bpel.ui.BPELMultiPageEditorActionBarContributor"
default="true"
+ icon="icons/obj16/bpel.gif"
id="org.eclipse.bpel.ui.bpeleditor"
name="%BPEL_EDITOR_NAME">
<!-- use content type to identify BPEL files // Bugzilla 320545: -->
@@ -573,7 +574,7 @@
<wizard
canFinishEarly="false"
category="org.eclipse.bpel.wizards"
- class="org.eclipse.bpel.ui.wizards.NewFileWizard"
+ class="org.eclipse.bpel.ui.wizards.NewBpelFileWizard"
hasPages="true"
icon="icons/obj16/bpel.gif"
id="org.eclipse.bpel.ui.newFile"
diff --git a/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/BPELUIPlugin.java b/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/BPELUIPlugin.java
index f35deb7..ac50205 100644
--- a/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/BPELUIPlugin.java
+++ b/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/BPELUIPlugin.java
@@ -41,7 +41,7 @@
public class BPELUIPlugin extends AbstractUIPlugin {
-
+
public static final String PLUGIN_ID = "org.eclipse.bpel.ui"; //$NON-NLS-1$
/** */
@@ -49,42 +49,42 @@
private ColorRegistry colorRegistry;
protected boolean imagesAndColorsInitialized;
-
+
// takes care of changes to the BPEL file
private BPELResourceChangeListener resourceChangeListener;
private ISaveParticipant saveParticipant;
// The templates that are provided for new file creation
private Templates mTemplates;
-
-
+
+
public BPELUIPlugin() {
super();
}
-
+
/**
* @param path
* @return return the plugin URI
*/
-
+
public URI getURI ( String path ) {
return URI.createPlatformPluginURI(getID() + path, false);
}
-
+
public String getDefaultPage() {
return getPreferenceStore().getString(IBPELUIConstants.DEFAULT_EDITOR_PAGE);
}
/**
* setDefaultPage
- * Set the default page to open when the editor starts.
+ * Set the default page to open when the editor starts.
* @param page
*/
public void setDefaultPage(String page) {
getPreferenceStore().setValue(IBPELUIConstants.DEFAULT_EDITOR_PAGE, page);
}
-
+
/**2
* Creates an image descriptor and places it in the image registry.
*/
@@ -109,82 +109,82 @@
public Image getImage(String id) {
return getImageRegistry().get(id);
}
-
-
+
+
public String getID () {
return getBundle().getSymbolicName();
}
-
-
+
+
private void initializeColors() {
- colorRegistry = new ColorRegistry();
-
+ this.colorRegistry = new ColorRegistry();
+
RGB color_240_240_240 = ColorUtils.getRelativeRGB(240, 240, 240);
RGB color_255_255_255 = ColorUtils.getRelativeRGB(255, 255, 255);
- colorRegistry.put(IBPELUIConstants.COLOR_FLOW_BORDER, ColorUtils.getRelativeRGB(112, 152, 224));
-
- colorRegistry.put(IBPELUIConstants.COLOR_GRADIENT_FROM, color_255_255_255);
- colorRegistry.put(IBPELUIConstants.COLOR_GRADIENT_TO, color_240_240_240);
-
+ this.colorRegistry.put(IBPELUIConstants.COLOR_FLOW_BORDER, ColorUtils.getRelativeRGB(112, 152, 224));
+
+ this.colorRegistry.put(IBPELUIConstants.COLOR_GRADIENT_FROM, color_255_255_255);
+ this.colorRegistry.put(IBPELUIConstants.COLOR_GRADIENT_TO, color_240_240_240);
+
if (ColorUtils.isInvertedColorScheme()) {
- colorRegistry.put(IBPELUIConstants.COLOR_ACTIVITY_BORDER, ColorUtils.getRelativeRGB(25, 25, 25));
- colorRegistry.put(IBPELUIConstants.COLOR_COMPOSITE_ACTIVITY_BORDER, ColorUtils.getRelativeRGB(25, 25, 25));
- colorRegistry.put(IBPELUIConstants.COLOR_SCOPE_BORDER, ColorUtils.getRelativeRGB(25, 25, 25));
- colorRegistry.put(IBPELUIConstants.COLOR_IMPLICIT_LINK, ColorUtils.getRelativeRGB(25, 25, 25));
+ this.colorRegistry.put(IBPELUIConstants.COLOR_ACTIVITY_BORDER, ColorUtils.getRelativeRGB(25, 25, 25));
+ this.colorRegistry.put(IBPELUIConstants.COLOR_COMPOSITE_ACTIVITY_BORDER, ColorUtils.getRelativeRGB(25, 25, 25));
+ this.colorRegistry.put(IBPELUIConstants.COLOR_SCOPE_BORDER, ColorUtils.getRelativeRGB(25, 25, 25));
+ this.colorRegistry.put(IBPELUIConstants.COLOR_IMPLICIT_LINK, ColorUtils.getRelativeRGB(25, 25, 25));
} else {
- colorRegistry.put(IBPELUIConstants.COLOR_ACTIVITY_BORDER, ColorUtils.getRelativeRGB(176, 176, 176));
- colorRegistry.put(IBPELUIConstants.COLOR_COMPOSITE_ACTIVITY_BORDER, ColorUtils.getRelativeRGB(205, 205, 205));
- colorRegistry.put(IBPELUIConstants.COLOR_SCOPE_BORDER, ColorUtils.getRelativeRGB(205, 205, 205));
- colorRegistry.put(IBPELUIConstants.COLOR_IMPLICIT_LINK, ColorUtils.getRelativeRGB(200, 200, 200));
+ this.colorRegistry.put(IBPELUIConstants.COLOR_ACTIVITY_BORDER, ColorUtils.getRelativeRGB(176, 176, 176));
+ this.colorRegistry.put(IBPELUIConstants.COLOR_COMPOSITE_ACTIVITY_BORDER, ColorUtils.getRelativeRGB(205, 205, 205));
+ this.colorRegistry.put(IBPELUIConstants.COLOR_SCOPE_BORDER, ColorUtils.getRelativeRGB(205, 205, 205));
+ this.colorRegistry.put(IBPELUIConstants.COLOR_IMPLICIT_LINK, ColorUtils.getRelativeRGB(200, 200, 200));
}
- colorRegistry.put(IBPELUIConstants.COLOR_HILIGHT_NODE, ColorUtils.getRelativeRGB(255, 255, 0));
- colorRegistry.put(IBPELUIConstants.COLOR_VARIABLE_BACKGROUND, ColorUtils.getRelativeRGB(255, 255, 255));
- colorRegistry.put(IBPELUIConstants.COLOR_VARIABLE_SEPARATOR, ColorUtils.getRelativeRGB(230, 230, 230));
- colorRegistry.put(IBPELUIConstants.COLOR_VARIABLE_REFERENCE, ColorUtils.getRelativeRGB(99, 151, 245));
- colorRegistry.put(IBPELUIConstants.COLOR_LINK_ONE, ColorUtils.getRelativeRGB(238, 197, 253));
- colorRegistry.put(IBPELUIConstants.COLOR_LINK_TWO, ColorUtils.getRelativeRGB(73, 0, 107));
- colorRegistry.put(IBPELUIConstants.COLOR_LINK_THREE, ColorUtils.getRelativeRGB(222, 144, 254));
-
- colorRegistry.put(IBPELUIConstants.COLOR_WHITE, ColorUtils.getRelativeRGB(255, 255, 255));
- colorRegistry.put(IBPELUIConstants.COLOR_BLACK, ColorUtils.getRelativeRGB(0,0,0));
- colorRegistry.put(IBPELUIConstants.COLOR_RED, ColorUtils.getRelativeRGB(255,0,0));
- colorRegistry.put(IBPELUIConstants.COLOR_DARK_RED, ColorUtils.getRelativeRGB(0x80, 0, 0));
- colorRegistry.put(IBPELUIConstants.COLOR_GREEN, ColorUtils.getRelativeRGB( 0, 255, 0));
- colorRegistry.put(IBPELUIConstants.COLOR_DARK_GREEN, ColorUtils.getRelativeRGB(0, 0x80, 0));
- colorRegistry.put(IBPELUIConstants.COLOR_YELLOW, ColorUtils.getRelativeRGB(255, 255, 0));
- colorRegistry.put(IBPELUIConstants.COLOR_DARK_YELLOW, ColorUtils.getRelativeRGB(0x80, 0x80, 0));
- colorRegistry.put(IBPELUIConstants.COLOR_BLUE, ColorUtils.getRelativeRGB( 0, 0 ,255));
- colorRegistry.put(IBPELUIConstants.COLOR_DARK_BLUE, ColorUtils.getRelativeRGB(0, 0, 0x80));
- colorRegistry.put(IBPELUIConstants.COLOR_MAGENTA, ColorUtils.getRelativeRGB( 255, 0, 255));
- colorRegistry.put(IBPELUIConstants.COLOR_DARK_MAGENTA, ColorUtils.getRelativeRGB( 0x80, 0, 0x80));
- colorRegistry.put(IBPELUIConstants.COLOR_CYAN, ColorUtils.getRelativeRGB( 0, 255, 255));
- colorRegistry.put(IBPELUIConstants.COLOR_DARK_CYAN, ColorUtils.getRelativeRGB( 0, 0x80, 0x80));
- colorRegistry.put(IBPELUIConstants.COLOR_GRAY, ColorUtils.getRelativeRGB( 0xC0, 0xC0, 0xC0));
- colorRegistry.put(IBPELUIConstants.COLOR_DARK_GRAY, ColorUtils.getRelativeRGB(0x80, 0x80, 0x80));
-
- colorRegistry.put(IBPELUIConstants.COLOR_HANDLER_LINK_FH, ColorUtils.getRelativeRGB(222,145,29));
- colorRegistry.put(IBPELUIConstants.COLOR_HANDLER_LINK_CH, ColorUtils.getRelativeRGB(124,151,203));
- colorRegistry.put(IBPELUIConstants.COLOR_HANDLER_LINK_EH, ColorUtils.getRelativeRGB(179,179,179));
- colorRegistry.put(IBPELUIConstants.COLOR_HANDLER_LINK_TH, ColorUtils.getRelativeRGB(255,0,0));
+ this.colorRegistry.put(IBPELUIConstants.COLOR_HILIGHT_NODE, ColorUtils.getRelativeRGB(255, 255, 0));
+ this.colorRegistry.put(IBPELUIConstants.COLOR_VARIABLE_BACKGROUND, ColorUtils.getRelativeRGB(255, 255, 255));
+ this.colorRegistry.put(IBPELUIConstants.COLOR_VARIABLE_SEPARATOR, ColorUtils.getRelativeRGB(230, 230, 230));
+ this.colorRegistry.put(IBPELUIConstants.COLOR_VARIABLE_REFERENCE, ColorUtils.getRelativeRGB(99, 151, 245));
+ this.colorRegistry.put(IBPELUIConstants.COLOR_LINK_ONE, ColorUtils.getRelativeRGB(238, 197, 253));
+ this.colorRegistry.put(IBPELUIConstants.COLOR_LINK_TWO, ColorUtils.getRelativeRGB(73, 0, 107));
+ this.colorRegistry.put(IBPELUIConstants.COLOR_LINK_THREE, ColorUtils.getRelativeRGB(222, 144, 254));
+
+ this.colorRegistry.put(IBPELUIConstants.COLOR_WHITE, ColorUtils.getRelativeRGB(255, 255, 255));
+ this.colorRegistry.put(IBPELUIConstants.COLOR_BLACK, ColorUtils.getRelativeRGB(0,0,0));
+ this.colorRegistry.put(IBPELUIConstants.COLOR_RED, ColorUtils.getRelativeRGB(255,0,0));
+ this.colorRegistry.put(IBPELUIConstants.COLOR_DARK_RED, ColorUtils.getRelativeRGB(0x80, 0, 0));
+ this.colorRegistry.put(IBPELUIConstants.COLOR_GREEN, ColorUtils.getRelativeRGB( 0, 255, 0));
+ this.colorRegistry.put(IBPELUIConstants.COLOR_DARK_GREEN, ColorUtils.getRelativeRGB(0, 0x80, 0));
+ this.colorRegistry.put(IBPELUIConstants.COLOR_YELLOW, ColorUtils.getRelativeRGB(255, 255, 0));
+ this.colorRegistry.put(IBPELUIConstants.COLOR_DARK_YELLOW, ColorUtils.getRelativeRGB(0x80, 0x80, 0));
+ this.colorRegistry.put(IBPELUIConstants.COLOR_BLUE, ColorUtils.getRelativeRGB( 0, 0 ,255));
+ this.colorRegistry.put(IBPELUIConstants.COLOR_DARK_BLUE, ColorUtils.getRelativeRGB(0, 0, 0x80));
+ this.colorRegistry.put(IBPELUIConstants.COLOR_MAGENTA, ColorUtils.getRelativeRGB( 255, 0, 255));
+ this.colorRegistry.put(IBPELUIConstants.COLOR_DARK_MAGENTA, ColorUtils.getRelativeRGB( 0x80, 0, 0x80));
+ this.colorRegistry.put(IBPELUIConstants.COLOR_CYAN, ColorUtils.getRelativeRGB( 0, 255, 255));
+ this.colorRegistry.put(IBPELUIConstants.COLOR_DARK_CYAN, ColorUtils.getRelativeRGB( 0, 0x80, 0x80));
+ this.colorRegistry.put(IBPELUIConstants.COLOR_GRAY, ColorUtils.getRelativeRGB( 0xC0, 0xC0, 0xC0));
+ this.colorRegistry.put(IBPELUIConstants.COLOR_DARK_GRAY, ColorUtils.getRelativeRGB(0x80, 0x80, 0x80));
+
+ this.colorRegistry.put(IBPELUIConstants.COLOR_HANDLER_LINK_FH, ColorUtils.getRelativeRGB(222,145,29));
+ this.colorRegistry.put(IBPELUIConstants.COLOR_HANDLER_LINK_CH, ColorUtils.getRelativeRGB(124,151,203));
+ this.colorRegistry.put(IBPELUIConstants.COLOR_HANDLER_LINK_EH, ColorUtils.getRelativeRGB(179,179,179));
+ this.colorRegistry.put(IBPELUIConstants.COLOR_HANDLER_LINK_TH, ColorUtils.getRelativeRGB(255,0,0));
}
-
+
/**
* TODO: registry should be moved to editors and removed from plug-in
*/
public ColorRegistry getColorRegistry() {
- if (colorRegistry == null) {
+ if (this.colorRegistry == null) {
initialize();
}
- return colorRegistry;
+ return this.colorRegistry;
}
-
+
@Override
public ImageRegistry getImageRegistry() {
ImageRegistry result = super.getImageRegistry();
initialize();
return result;
}
-
+
/**
* Initializes the table of images used in this plugin.
*/
@@ -194,10 +194,9 @@
// A little reflection magic ... so that we don't
// have to add the createImageDescriptor every time
// we add it to the IBPELUIConstants ..
- Field fields[] = IBPELUIConstants.class.getFields();
- for(int i=0; i < fields.length; i++) {
- Field f = fields[i];
- if (f.getType() != String.class) {
+ Field fields[] = IBPELUIConstants.class.getFields();
+ for( Field f : fields ) {
+ if (f.getType() != String.class) {
continue;
}
String name = f.getName();
@@ -208,7 +207,7 @@
} catch (Exception e) {
log(e);
}
- }
+ }
}
}
@@ -219,40 +218,41 @@
public void start(BundleContext context) throws Exception {
super.start(context);
INSTANCE = this;
-
+
initializePreferences();
initializeResourceChangeListener();
initFunctions ();
}
protected void initializePreferences() {
- IPreferenceStore store = getPreferenceStore();
+ IPreferenceStore store = getPreferenceStore();
store.setDefault(IBPELUIConstants.PREF_SHOW_FREEFORM_FLOW, true);
store.setDefault(IBPELUIConstants.PREF_WARN_LINKS, true);
store.setDefault(IBPELUIConstants.PREF_AUTO_FLOW_LAYOUT, false);
store.setDefault(IBPELUIConstants.PREF_USE_ANIMATION, true);
store.setDefault(IBPELUIConstants.PREF_CREATE_SPEC_COMPLIANT_PROCESS, false);
}
-
-
+
+
/**
* Installs the IResourceChangeListener for the BPEL Plugin. Also
* checks if there were any changes to BPEL files while the plug-in
* was not active.
*/
private void initializeResourceChangeListener() throws CoreException {
- resourceChangeListener = new BPELResourceChangeListener();
+ this.resourceChangeListener = new BPELResourceChangeListener();
// Add the save participant in a separate thread
// to make sure that it doesn't block the UI thread and potentially cause
// deadlocks with the code that caused our plugin to be started.
Thread initSaveParticipantThread = new Thread(new Runnable() {
+ @Override
public void run() {
try {
IWorkspace workspace = ResourcesPlugin.getWorkspace();
- workspace.addResourceChangeListener(resourceChangeListener, IResourceChangeEvent.POST_BUILD);
+ workspace.addResourceChangeListener(BPELUIPlugin.this.resourceChangeListener, IResourceChangeEvent.POST_BUILD);
ISavedState savedState = workspace.addSaveParticipant(BPELUIPlugin.this, getSaveParticipant());
if (savedState != null) {
- savedState.processResourceChangeEvents(resourceChangeListener);
+ savedState.processResourceChangeEvents(BPELUIPlugin.this.resourceChangeListener);
}
} catch (CoreException e) {
throw new RuntimeException(e);
@@ -267,30 +267,30 @@
return false;
}
-
-
+
+
public Templates getTemplates ()
{
- if (mTemplates == null) {
- mTemplates = new Templates ();
- mTemplates.initializeFrom( getBundle() );
+ if (this.mTemplates == null) {
+ this.mTemplates = new Templates ();
+ this.mTemplates.initializeFrom( getBundle() );
}
- return mTemplates;
+ return this.mTemplates;
}
-
-
+
+
protected void initialize() {
- if (!imagesAndColorsInitialized) {
- imagesAndColorsInitialized = true;
+ if (!this.imagesAndColorsInitialized) {
+ this.imagesAndColorsInitialized = true;
initializeImages();
- initializeColors();
- }
+ initializeColors();
+ }
}
-
-
+
+
@SuppressWarnings("nls")
void initFunctions () {
-
+
Job job = new Job ("Reading XPath Function Registry ...") {
@Override
@@ -298,22 +298,22 @@
long start = System.currentTimeMillis();
IStatus status;
try {
- Functions.getInstance( BPELConstants.XMLNS_XPATH_EXPRESSION_LANGUAGE );
+ Functions.getInstance( BPELConstants.XMLNS_XPATH_EXPRESSION_LANGUAGE );
status = new Status(IStatus.OK, PLUGIN_ID, 0, "Done",null); //$NON-NLS-1$
- } catch (Throwable t ) {
+ } catch (Throwable t ) {
log(t);
- status = new Status(IStatus.ERROR,PLUGIN_ID,0,t.getLocalizedMessage(),t);
- }
+ status = new Status(IStatus.ERROR,PLUGIN_ID,0,t.getLocalizedMessage(),t);
+ }
long end = System.currentTimeMillis();
System.out.println("InitFunctions took: " + (end - start) + "ms");
-
+
monitor.done();
- done(Job.ASYNC_FINISH);
- return status;
- }
- };
-
- job.setPriority(Job.SHORT);
+ done(Job.ASYNC_FINISH);
+ return status;
+ }
+ };
+
+ job.setPriority(Job.SHORT);
job.schedule();
}
@@ -327,63 +327,67 @@
IWorkspace workspace = ResourcesPlugin.getWorkspace();
if (workspace != null) {
- workspace.removeResourceChangeListener(resourceChangeListener);
+ workspace.removeResourceChangeListener(this.resourceChangeListener);
}
}
-
+
/**
* We are only interested in the resource delta while the plugin was
* not active and don't really care about the plug-in save lifecycle.
*/
private ISaveParticipant getSaveParticipant() {
- if (saveParticipant == null) {
- saveParticipant = new ISaveParticipant() {
+ if (this.saveParticipant == null) {
+ this.saveParticipant = new ISaveParticipant() {
+ @Override
public void doneSaving(ISaveContext context) {
}
+ @Override
public void prepareToSave(ISaveContext context) throws CoreException {
}
+ @Override
public void rollback(ISaveContext context) {
}
+ @Override
public void saving(ISaveContext context) throws CoreException {
context.needDelta();
}
};
}
- return saveParticipant;
+ return this.saveParticipant;
}
-
+
/**
* Returns the resource change listener.
*/
public BPELResourceChangeListener getResourceChangeListener() {
- return resourceChangeListener;
+ return this.resourceChangeListener;
}
/**
* Return the dialog settings for a given object. The object may be a string
* or any other java object. In that case, the object's class name will be used
* to retrieve that section name.
- *
- * @param object
+ *
+ * @param object
* @return the dialog settings for that object
- *
+ *
*/
- public IDialogSettings getDialogSettingsFor ( Object object )
+ public IDialogSettings getDialogSettingsFor ( Object object )
{
String name = object.getClass().getName();
if (object instanceof String) {
name = (String) object;
}
-
- IDialogSettings main = getDialogSettings();
+
+ IDialogSettings main = getDialogSettings();
IDialogSettings settings = main.getSection( name );
if (settings == null) {
settings = main.addNewSection(name);
}
return settings;
}
-
-
+
+
/**
* Utility methods for logging exceptions.
*/
@@ -398,7 +402,19 @@
System.out.println(e.getClass().getName()+": "+status); //$NON-NLS-1$
INSTANCE.getLog().log(status);
}
-
- public static void log(Throwable throwable) {
+
+
+ /**
+ * Utility methods for logging exceptions.
+ */
+ public static void log( Throwable e, String message, int severity ) {
+ IStatus status = new Status( severity, PLUGIN_ID, message, e );
+ INSTANCE.getLog().log( status );
+ }
+
+ /**
+ * @param throwable
+ */
+ public static void log(Throwable throwable) {
log(throwable, IStatus.ERROR); }
}
diff --git a/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/wizards/BPELCreateOperation.java b/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/wizards/BPELCreateOperation.java
deleted file mode 100644
index 893f237..0000000
--- a/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/wizards/BPELCreateOperation.java
+++ /dev/null
@@ -1,168 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 Oracle Corporation and others.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle Corporation
- *******************************************************************************/
-
-package org.eclipse.bpel.ui.wizards;
-
-import java.io.ByteArrayInputStream;
-import java.io.InputStream;
-import java.lang.reflect.InvocationTargetException;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.bpel.ui.BPELUIPlugin;
-import org.eclipse.bpel.ui.Templates;
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-
-
-/**
- * This class defines the BPEL Project creation operation.
- *
- * @author Edwin Khodabakchian (edwin.khodabakchian@oracle.com)
- * @author Michal Chmielewski (michal.chmielewski@oracle.com)
- *
- */
-
-public class BPELCreateOperation implements IRunnableWithProgress {
-
- // The element to open
- private IResource mElementToOpen;
-
- // Process name, namespace from the wizard pages
- private Map mArgs ;
-
- // The container where we should create the BPEL file/process
- private IContainer mContainer ;
-
- // The template from which we will be creating the file(s)
- private Templates.Template mTemplate;
-
-
- public void setArgs(Map args) {
- mArgs = args;
- }
-
-
- public void setContainer(IContainer container) {
- mContainer = container;
- }
-
- public void setTemplate(Templates.Template template) {
- mTemplate = template;
- }
-
-
-
- /**
- * Runs the creation operation. This basically involves getting the templates and
- * creating the initial project.
- *
- * @param monitor the monitor to use
- * @throws InvocationTargetException
- * @throws InterruptedException
- *
- * @see IRunnableWithProgress#run(IProgressMonitor)
- */
-
- public void run(IProgressMonitor monitor)
- throws InvocationTargetException, InterruptedException
- {
- if (monitor == null) {
- monitor= new NullProgressMonitor();
- }
- mElementToOpen = null;
-
-
- List resources = mTemplate.getResources();
- monitor.beginTask(Messages.BPELCreateOperation_0, resources.size());
-
- Iterator ii = resources.iterator();
- while (ii.hasNext()) {
-
- Templates.TemplateResource resource = (Templates.TemplateResource) ii.next();
-
- String result = resource.process( mArgs );
- try {
- IFile file = save (mContainer, resource.getName( mArgs ), result );
- if (mElementToOpen == null && resource.isProcess ()) {
- mElementToOpen = file;
- }
- } catch (CoreException ce) {
- BPELUIPlugin.log(ce);
- }
- monitor.worked(1);
- }
-
- monitor.done();
-
- }
-
-
- /**
- * Return the resource to open when when a base definition of the project is created.
- * @return an IResource that should be auto-magically opened.
- */
-
- public IResource getElementToOpen() {
- return mElementToOpen;
- }
-
- /**
- * Save the content of the file indicated by fName to the container passed.
- * May throw an exception
- *
- * @param container the container where the save should take place.
- * @param fName the file name where the save should take place.
- * @param content the content to save *
- * @throws CoreException if something bad happens
- *
- */
-
- private IFile save ( IContainer container,
- String fName,
- String content
- ) throws CoreException
- {
- IFile file = container.getFile(new Path(fName));
- InputStream stream = new ByteArrayInputStream( content.getBytes() );
- try
- {
- if (file.exists())
- {
- file.setContents(stream, true, true, null);
- }
- else
- {
- file.create(stream, true, null);
- }
- }
- finally
- {
- try {
- stream.close();
- } catch (Exception ex) {
- // ignore
- }
- }
-
- return file;
- }
-
-}
-
diff --git a/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/wizards/NewBpelFileFirstPage.java b/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/wizards/NewBpelFileFirstPage.java
new file mode 100644
index 0000000..5f355de
--- /dev/null
+++ b/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/wizards/NewBpelFileFirstPage.java
@@ -0,0 +1,323 @@
+/*******************************************************************************
+ * Copyright (c) 2006 Oracle Corporation and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Oracle Corporation
+ *******************************************************************************/
+
+package org.eclipse.bpel.ui.wizards;
+
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.bpel.common.ui.details.viewers.ComboViewer;
+import org.eclipse.bpel.model.util.BPELConstants;
+import org.eclipse.bpel.ui.BPELUIPlugin;
+import org.eclipse.bpel.ui.IBPELUIConstants;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jface.dialogs.IDialogSettings;
+import org.eclipse.jface.viewers.ArrayContentProvider;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.wizard.IWizardPage;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+
+/**
+ * The first page of the wizard to create a new BPEL process.
+ * <p>
+ * This page deals with the creation mode and the general properties of the BPEL to create.
+ * </p>
+ *
+ * @author Michal Chmielewski - Oracle
+ * @author Vincent Zurczak - EBM WebSourcing
+ */
+public class NewBpelFileFirstPage extends WizardPage {
+
+ /**
+ * The page's name, so that it can be referenced from other pages.
+ */
+ public static final String PAGE_NAME = "bpel-first-page";
+
+ /**
+ * The creation mode.
+ */
+ private BpelCreationMode creationMode;
+
+ /**
+ * The process name and name space.
+ */
+ private String processName, processNamespace;
+
+ /**
+ * True to create an abstract process, false otherwise.
+ */
+ private boolean abstractProcess;
+
+ /**
+ * The properties to pass to the template.
+ */
+ private final Map<String,Object> processTemplateProperties;
+
+
+ /**
+ * Constructor.
+ */
+ public NewBpelFileFirstPage() {
+ super( PAGE_NAME );
+
+ setTitle( Messages.NewFileWizardPage1_2 );
+ setDescription( Messages.NewFileWizardPage1_3 );
+ setImageDescriptor( BPELUIPlugin.INSTANCE.getImageDescriptor( IBPELUIConstants.ICON_WIZARD_BANNER ));
+
+ this.processTemplateProperties = new HashMap<String,Object> ();
+ }
+
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.wizard.WizardPage
+ * #getNextPage()
+ */
+ @Override
+ public IWizardPage getNextPage() {
+
+ IWizardPage nextPage;
+ if( this.creationMode == BpelCreationMode.CREATE_NEW_BPEL )
+ nextPage = getWizard().getPage( NewBpelFileWsdlPage.PAGE_NAME );
+ else
+ nextPage = getWizard().getPage( NewBpelFilePortTypePage.PAGE_NAME );
+
+ nextPage.setPreviousPage( this );
+ return nextPage;
+ }
+
+
+ /**
+ * @return the properties for the templates
+ */
+ public Map<String,Object> getProcessTemplateProperties() {
+ return this.processTemplateProperties;
+ }
+
+
+ /**
+ * @return the creationMode
+ */
+ public BpelCreationMode getCreationMode() {
+ return this.creationMode;
+ }
+
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.IDialogPage
+ * #createControl(org.eclipse.swt.widgets.Composite)
+ */
+ @Override
+ public void createControl( Composite parent ) {
+
+ // Create the container
+ final Composite container = new Composite( parent, SWT.NONE );
+ container.setFont( parent.getFont());
+ initializeDialogUnits( parent );
+ container.setLayout( new GridLayout( 2, false ));
+ container.setLayoutData( new GridData( GridData.FILL_BOTH ));
+ setControl( container );
+
+
+ // Add a combo to select the creation mode
+ Label label = new Label( container, SWT.NONE );
+ label.setText( "Creation Mode:" );
+ label.setToolTipText( "Select the way to create a new BPEL process" );
+
+ final ComboViewer creationViewer = new ComboViewer( container, SWT.BORDER | SWT.DROP_DOWN | SWT.READ_ONLY );
+ creationViewer.setContentProvider( new ArrayContentProvider());
+ creationViewer.setLabelProvider( new LabelProvider());
+ creationViewer.setInput( BpelCreationMode.values());
+
+
+ // Add the other common widgets
+ Label l = new Label( container, SWT.NONE );
+ l.setText( Messages.NewFileWizardPage1_5 );
+ l.setToolTipText( "The name of the BPEL process" );
+
+ Text processNameText = new Text( container, SWT.BORDER | SWT.SINGLE );
+ processNameText.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ));
+ if( this.processName != null )
+ processNameText.setText( this.processName );
+
+ processNameText.addModifyListener( new ModifyListener() {
+ @Override
+ public void modifyText( ModifyEvent e ) {
+ NewBpelFileFirstPage.this.processName = ((Text) e.widget).getText();
+ updateStatus();
+ }
+ });
+
+
+ l = new Label( container, SWT.NONE );
+ l.setText( Messages.NewFileWizardPage1_6 );
+ l.setToolTipText( "The target namespace of the BPEL process" );
+
+ Combo processNamespaceCombo = new Combo( container, SWT.DROP_DOWN | SWT.SIMPLE );
+ processNamespaceCombo.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ));
+ processNamespaceCombo.setItems( BPELUIPlugin.INSTANCE.getTemplates().getNamespaceNames());
+ if( this.processNamespace != null )
+ processNamespaceCombo.setText( this.processNamespace );
+
+ processNamespaceCombo.addModifyListener( new ModifyListener() {
+ @Override
+ public void modifyText( ModifyEvent e ) {
+ NewBpelFileFirstPage.this.processNamespace = ((Combo) e.widget).getText();
+ updateStatus();
+ }
+ });
+
+
+ new Label( container, SWT.NONE );
+ final Button abstractProcessButton = new Button( container, SWT.CHECK );
+ abstractProcessButton.setText( "Abstract Process" );
+ abstractProcessButton.setToolTipText( "Make the created process abstract" );
+ abstractProcessButton.addSelectionListener( new SelectionListener() {
+ @Override
+ public void widgetSelected( SelectionEvent e ) {
+ widgetDefaultSelected( e );
+ }
+
+ @Override
+ public void widgetDefaultSelected( SelectionEvent e ) {
+ NewBpelFileFirstPage.this.abstractProcess = ((Button) e.widget).getSelection();
+ updateStatus();
+ }
+ });
+
+
+ // Detect when the creation mode changes
+ creationViewer.addSelectionChangedListener( new ISelectionChangedListener() {
+ @Override
+ public void selectionChanged( SelectionChangedEvent event ) {
+ NewBpelFileFirstPage.this.creationMode = (BpelCreationMode) ((IStructuredSelection) creationViewer.getSelection()).getFirstElement();
+ updateStatus();
+ }
+ });
+
+
+ // Add an image to illustrate the creation mode
+
+
+ // Initialize all the stuff
+ creationViewer.setSelection( new StructuredSelection( BpelCreationMode.CREATE_NEW_BPEL ));
+ creationViewer.getCombo().notifyListeners( SWT.Selection, new Event());
+ if( getErrorMessage() != null ) {
+ setPageComplete( false );
+ setErrorMessage( null );
+ }
+ }
+
+
+ /**
+ * Validates the page data and updates the page state in consequence.
+ */
+ private void updateStatus() {
+ String errorMsg = validatePage();
+ setPageComplete( errorMsg == null );
+ setErrorMessage( errorMsg );
+ }
+
+
+ /**
+ * Validates the page data and stores valid values for further use.
+ * @return an error message or null if everything is right
+ */
+ private String validatePage() {
+
+ String errorMsg = null;
+
+ // Validate the page fields
+ IStatus nameStatus;
+ if( this.processName == null || this.processName.trim().length() == 0 )
+ errorMsg = "You have to specify the process name.";
+
+ else if( this.processName.matches( "\\s" ))
+ errorMsg = "The process name cannot contain spaces or white characters.";
+
+ else if( ! ( nameStatus = ResourcesPlugin.getWorkspace().validateName( this.processName, IResource.FILE )).isOK())
+ errorMsg = nameStatus.getMessage();
+
+ else if( this.processNamespace == null || this.processNamespace.trim().length() == 0 )
+ errorMsg = "You have to specify the process namespace.";
+
+
+ // No error => store properties for the templates
+ if( errorMsg == null
+ && this.creationMode == BpelCreationMode.CREATE_NEW_BPEL ) {
+
+ String bpelNamespace = this.abstractProcess ? BPELConstants.NAMESPACE_ABSTRACT_2007 : BPELConstants.NAMESPACE;
+ this.processTemplateProperties.put( "processName", this.processName ); //$NON-NLS-1$
+ this.processTemplateProperties.put( "namespace", this.processNamespace ); //$NON-NLS-1$
+ this.processTemplateProperties.put( "bpelNamespace", bpelNamespace ); //$NON-NLS-1$
+ this.processTemplateProperties.put( "date", new Date()); //$NON-NLS-1$
+ }
+
+
+ // Save some fields for further use
+ IDialogSettings settings = getWizard().getDialogSettings();
+ settings.put( NewBpelFileWizard.DIALOG_SETTINGS_PROCESS_NAME, this.processName );
+
+ return errorMsg;
+ }
+
+
+ /**
+ * The different modes to create a new BPEL to edit.
+ */
+ public static enum BpelCreationMode {
+ CREATE_NEW_BPEL, GENERATE_BPEL_FROM_WSDL;
+
+ /*
+ * (non-Javadoc)
+ * @see java.lang.Enum#toString()
+ */
+ @Override
+ public String toString() {
+
+ String result;
+ switch( this ) {
+ case CREATE_NEW_BPEL:
+ result = "Create a BPEL process from a template";
+ break;
+ case GENERATE_BPEL_FROM_WSDL:
+ result = "Create a BPEL process from a service description";
+ break;
+ default:
+ result = "";
+ }
+
+ return result;
+ };
+ }
+}
diff --git a/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/wizards/NewBpelFileLocationPage.java b/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/wizards/NewBpelFileLocationPage.java
new file mode 100644
index 0000000..aa9f0c5
--- /dev/null
+++ b/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/wizards/NewBpelFileLocationPage.java
@@ -0,0 +1,122 @@
+/*******************************************************************************
+ * Copyright (c) 2006 Oracle Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Oracle Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.bpel.ui.wizards;
+
+import org.eclipse.bpel.ui.BPELUIPlugin;
+import org.eclipse.bpel.ui.IBPELUIConstants;
+import org.eclipse.bpel.ui.util.BPELUtil;
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.ui.dialogs.WizardNewFileCreationPage;
+
+/**
+ * The wizard page to define the location of the new BPEL process to create.
+ * @author Michal Chmielewski - Oracle
+ * @author Vincent Zurczak - EBM WebSourcing
+ */
+public class NewBpelFileLocationPage extends WizardNewFileCreationPage {
+
+ /**
+ * The page's name, so that it can be referenced from other pages.
+ */
+ public static final String PAGE_NAME = "location-page";
+
+ private IContainer resourceContainer;
+
+
+ /**
+ * Constructor.
+ */
+ public NewBpelFileLocationPage( IStructuredSelection selection ) {
+ super( PAGE_NAME, selection );
+
+ setTitle( Messages.NewFileWizardPage2_3 );
+ setDescription( Messages.NewFileWizardPage2_0 );
+ setImageDescriptor( BPELUIPlugin.INSTANCE.getImageDescriptor( IBPELUIConstants.ICON_WIZARD_BANNER ));
+
+ setFileExtension( "bpel" );
+ setAllowExistingResources( false );
+ }
+
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.dialogs.WizardNewFileCreationPage
+ * #setVisible(boolean)
+ */
+ @Override
+ public void setVisible( boolean visible ) {
+
+ // Update some fields
+ String pName = getWizard().getDialogSettings().get( NewBpelFileWizard.DIALOG_SETTINGS_PROCESS_NAME );
+ if( pName != null )
+ setFileName( pName + ".bpel" );
+
+ // Do the usual work
+ super.setVisible( visible );
+ }
+
+
+ /**
+ * @return the container in which the resources will be created
+ */
+ public IContainer getResourceContainer() {
+ return this.resourceContainer;
+ }
+
+
+ /**
+ * @return the process file to create
+ */
+ public IFile getProcessFile() {
+ return this.resourceContainer.getFile( new Path( getFileName()));
+ }
+
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.dialogs.WizardNewFileCreationPage
+ * #validatePage()
+ */
+ @Override
+ protected boolean validatePage() {
+
+ setMessage( null, WizardPage.WARNING );
+ boolean valid = super.validatePage();
+ if( valid ) {
+
+ // Get the container
+ IPath path = getContainerFullPath();
+ if( path.segmentCount() == 1 )
+ this.resourceContainer = ResourcesPlugin.getWorkspace().getRoot().getProject( path.segment( 0 ));
+ else
+ this.resourceContainer = ResourcesPlugin.getWorkspace().getRoot().getFolder( path );
+
+ // Validate it
+ if( ! BPELUtil.isBPELProject( this.resourceContainer.getProject())) {
+ setMessage( Messages.NewFileWizard_Not_A_BPELFaceted_Project, WizardPage.WARNING );
+ valid = true;
+ }
+ else if( ! this.resourceContainer.equals( BPELUtil.getBPELContentFolder( this.resourceContainer.getProject()))) {
+ setMessage( Messages.NewFileWizard_Not_A_BPELContent_Folder, WizardPage.WARNING );
+ valid = true;
+ }
+ }
+
+ return valid;
+ }
+}
diff --git a/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/wizards/NewBpelFilePortTypePage.java b/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/wizards/NewBpelFilePortTypePage.java
new file mode 100644
index 0000000..f427151
--- /dev/null
+++ b/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/wizards/NewBpelFilePortTypePage.java
@@ -0,0 +1,481 @@
+/******************************************************************************
+ * Copyright (c) 2011, EBM WebSourcing
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * EBM WebSourcing - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.bpel.ui.wizards;
+
+import java.io.File;
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+import org.eclipse.bpel.common.ui.details.viewers.ComboViewer;
+import org.eclipse.bpel.common.wsdl.parsers.WsdlParser;
+import org.eclipse.bpel.ui.BPELUIPlugin;
+import org.eclipse.bpel.ui.IBPELUIConstants;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.viewers.ArrayContentProvider;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.wizard.IWizardPage;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.FocusAdapter;
+import org.eclipse.swt.events.FocusEvent;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.FileDialog;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.wst.wsdl.Definition;
+import org.eclipse.wst.wsdl.Fault;
+import org.eclipse.wst.wsdl.Input;
+import org.eclipse.wst.wsdl.Operation;
+import org.eclipse.wst.wsdl.Output;
+import org.eclipse.wst.wsdl.PortType;
+
+/**
+ * The page of the wizard to select the contract to implement.
+ * <p>
+ * This page could have to deal with several contracts to implement.
+ * </p>
+ * <p>
+ * Notice that this class uses WSDL4j to parse WSDL files, and not EMF.
+ * The reason is that EMF does not cross file inclusions and thus results in incomplete
+ * parsing or in failures with valid WSDL definitions.
+ * </p>
+ *
+ * @author Michal Chmielewski - Oracle
+ * @author Vincent Zurczak - EBM WebSourcing
+ */
+public class NewBpelFilePortTypePage extends WizardPage {
+
+ /**
+ * The page's name, so that it can be referenced from other pages.
+ */
+ public static final String PAGE_NAME = "port-type-page";
+
+ /**
+ * The WSDL URL.
+ */
+ private String wsdlUrl;
+
+ /**
+ * The selected port type in the WSDL.
+ */
+ private PortType portType;
+
+ /**
+ * True to import the selected WSDL at the end.
+ */
+ private boolean importWsdl = true;
+
+
+ /**
+ * Constructor.
+ */
+ public NewBpelFilePortTypePage() {
+ super( PAGE_NAME );
+
+ setTitle( "Service Contract" );
+ setDescription( "Select the service contract the BPEL process must implement." );
+ setImageDescriptor( BPELUIPlugin.INSTANCE.getImageDescriptor( IBPELUIConstants.ICON_WIZARD_BANNER ));
+ }
+
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.wizard.WizardPage
+ * #getNextPage()
+ */
+ @Override
+ public IWizardPage getNextPage() {
+
+ // We need to do that since the page order depends on user choices
+ IWizardPage nextPage = getWizard().getPage( NewBpelFileLocationPage.PAGE_NAME );
+ nextPage.setPreviousPage( this );
+ return nextPage;
+ }
+
+
+ /**
+ * @return the wsdlUrl
+ */
+ public String getWsdlUrl() {
+ return this.wsdlUrl;
+ }
+
+
+ /**
+ * @return the importWsdl
+ */
+ public boolean isImportWsdl() {
+ return this.importWsdl;
+ }
+
+
+ /**
+ * @return the portType
+ */
+ public PortType getPortType() {
+ return this.portType;
+ }
+
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.IDialogPage
+ * #createControl(org.eclipse.swt.widgets.Composite)
+ */
+ @Override
+ public void createControl( Composite parent ) {
+
+ // Create the container
+ final Composite container = new Composite( parent, SWT.NONE );
+ container.setFont( parent.getFont());
+ initializeDialogUnits( parent );
+ container.setLayout( new GridLayout( 2, false ));
+ container.setLayoutData( new GridData( GridData.FILL_BOTH ));
+ setControl( container );
+
+
+ // WSDL location (as an URL)
+ Label l = new Label( container, SWT.NONE );
+ l.setText( "WSDL URL:" );
+ l.setToolTipText( "The URL of the service description (WSDL)" );
+
+ Composite subContainer = new Composite( container, SWT.NONE );
+ GridLayout layout = new GridLayout( 2, false );
+ layout.marginHeight = 0;
+ layout.marginWidth = 0;
+ subContainer.setLayout( layout );
+ subContainer.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ));
+
+ final Text wsdlUrlText = new Text( subContainer, SWT.SINGLE | SWT.BORDER );
+ wsdlUrlText.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ));
+ if( this.wsdlUrl != null )
+ wsdlUrlText.setText( this.wsdlUrl );
+
+ wsdlUrlText.addModifyListener( new ModifyListener() {
+ @Override
+ public void modifyText( ModifyEvent e ) {
+ NewBpelFilePortTypePage.this.wsdlUrl = ((Text) e.widget).getText();
+ updateStatus();
+ }
+ });
+
+ Button browseButton = new Button( subContainer, SWT.PUSH );
+ browseButton.setText( "Browse..." );
+
+
+ // Port type to use for the generation
+ l = new Label( container, SWT.NONE );
+ l.setText( "Service Contract:" );
+ l.setToolTipText( "The port type (service contract) to implement with BPEL" );
+
+ final ComboViewer portTypeCombo = new ComboViewer( container, SWT.BORDER | SWT.DROP_DOWN | SWT.READ_ONLY );
+ portTypeCombo.getCombo().setLayoutData( new GridData( GridData.FILL_HORIZONTAL ));
+ portTypeCombo.setContentProvider( new ArrayContentProvider());
+ portTypeCombo.setLabelProvider( new LabelProvider() {
+ @Override
+ public String getText( Object element ) {
+ QName name = ((PortType) element).getQName();
+ return name.getLocalPart() + " - " + name.getNamespaceURI();
+ }
+ });
+
+
+ // The button to import the WSDL
+ new Label( container, SWT.NONE );
+ Button importButton = new Button( container, SWT.CHECK );
+ importButton.setText( "Import the WSDL file with its dependencies" );
+ importButton.setSelection( this.importWsdl );
+ importButton.addSelectionListener( new SelectionListener() {
+ @Override
+ public void widgetSelected( SelectionEvent e ) {
+ widgetDefaultSelected( e );
+ }
+
+ @Override
+ public void widgetDefaultSelected( SelectionEvent e ) {
+ NewBpelFilePortTypePage.this.importWsdl = ((Button) e.widget).getSelection();
+ }
+ });
+
+
+ // The viewer for a quick overview of the operations
+ subContainer = new Composite( container, SWT.NONE );
+ layout = new GridLayout();
+ layout.marginWidth = 0;
+ layout.marginTop = 11;
+ subContainer.setLayout( layout );
+ GridData layoutData = new GridData( GridData.FILL_BOTH );
+ layoutData.horizontalSpan = 2;
+ subContainer.setLayoutData( layoutData );
+
+ l = new Label( subContainer, SWT.NONE );
+ l.setText( "Select a service contract (port type) and see its operations below." );
+
+ final TreeViewer operationsViewer = new TreeViewer( subContainer, SWT.BORDER );
+ operationsViewer.getTree().setLayoutData( new GridData( GridData.FILL_BOTH ));
+ operationsViewer.setLabelProvider( new LabelProvider () {
+ @Override
+ public Image getImage( Object element ) {
+
+ Image result = null;
+ if( element instanceof Operation )
+ result = BPELUIPlugin.INSTANCE.getImage( IBPELUIConstants.ICON_OPERATION_16 );
+ else if( element instanceof Input )
+ result = BPELUIPlugin.INSTANCE.getImage( IBPELUIConstants.ICON_INPUT_16 );
+ else if( element instanceof Output )
+ result = BPELUIPlugin.INSTANCE.getImage( IBPELUIConstants.ICON_OUTPUT_16 );
+ else if( element instanceof Fault )
+ result = BPELUIPlugin.INSTANCE.getImage( IBPELUIConstants.ICON_FAULT_16 );
+
+ return result;
+ }
+
+ @Override
+ public String getText( Object element ) {
+
+ String result = "";
+ if( element instanceof Operation ) {
+ result = ((Operation) element).getName();
+ result = result == null || result.trim().length() == 0 ? "?" : result;
+
+ } else if( element instanceof Input ) {
+ result = ((Input) element).getName();
+ result = result == null || result.trim().length() == 0 ? "Input" : result;
+
+ } else if( element instanceof Output ) {
+ result = ((Output) element).getName();
+ result = result == null || result.trim().length() == 0 ? "Output" : result;
+
+ } else if( element instanceof Fault ) {
+ result = ((Fault) element).getName();
+ result = result == null || result.trim().length() == 0 ? "Fault" : result;
+ }
+
+ return result;
+ }
+ });
+
+ operationsViewer.setContentProvider( new ITreeContentProvider() {
+ @Override
+ public void dispose() {
+ // nothing
+ }
+
+ @Override
+ public void inputChanged( Viewer viewer, Object oldInput, Object newInput ) {
+ // nothing
+ }
+
+ @Override
+ public Object[] getElements( Object inputElement ) {
+ return ((PortType) inputElement).getOperations().toArray();
+ }
+
+ @SuppressWarnings( "unchecked" )
+ @Override
+ public Object[] getChildren( Object pa ) {
+
+ List<Object> result = new ArrayList<Object> ();
+ if( pa instanceof Operation ) {
+ Operation op = (Operation) pa;
+ if( op.getInput() != null )
+ result.add( op.getInput());
+
+ if( op.getOutput() != null )
+ result.add( op.getOutput());
+
+ if( op.getFaults() != null )
+ result.addAll( op.getFaults().values());
+ }
+
+ return result.toArray();
+ }
+
+ @Override
+ public Object getParent( Object element ) {
+ return null;
+ }
+
+ @Override
+ public boolean hasChildren( Object element ) {
+ return element instanceof Operation;
+ }
+ });
+
+
+ // Listeners
+ portTypeCombo.addSelectionChangedListener( new ISelectionChangedListener() {
+ @Override
+ public void selectionChanged( SelectionChangedEvent event ) {
+ NewBpelFilePortTypePage.this.portType = (PortType) ((IStructuredSelection) portTypeCombo.getSelection()).getFirstElement();
+ operationsViewer.setInput( NewBpelFilePortTypePage.this.portType );
+ operationsViewer.refresh();
+
+ if( NewBpelFilePortTypePage.this.portType != null ) {
+ if( NewBpelFilePortTypePage.this.portType.getOperations().size() < 4 )
+ operationsViewer.expandAll();
+ else
+ operationsViewer.expandToLevel( 2 );
+ }
+
+ updateStatus();
+ }
+ });
+
+
+ // WSDL parsing
+ final List<PortType> portTypes = new ArrayList<PortType> ();
+ final IRunnableWithProgress wsdlParsingOperation = new IRunnableWithProgress() {
+ @Override
+ public void run( IProgressMonitor monitor )
+ throws InvocationTargetException, InterruptedException {
+
+ monitor.beginTask( "Parsing the WSDL...", 5 );
+ try {
+ portTypes.clear();
+ monitor.worked( 1 );
+
+ URI emfUri = URI.createURI( NewBpelFilePortTypePage.this.wsdlUrl.toString());
+ Collection<Definition> definitions = WsdlParser.loadAllWsdlDefinitions( emfUri, WsdlParser.createBasicResourceSetForWsdl());
+ for( Definition def : definitions ) {
+ for( Object o : def.getPortTypes().values())
+ portTypes.add((PortType) o );
+ }
+
+ monitor.worked( 3 );
+
+ } finally {
+ monitor.done();
+ }
+ }
+ };
+
+ wsdlUrlText.addFocusListener( new FocusAdapter() {
+ @Override
+ public void focusLost( FocusEvent e ) {
+
+ if( NewBpelFilePortTypePage.this.wsdlUrl == null )
+ return;
+
+ try {
+ // Parse
+ getContainer().run( true, false, wsdlParsingOperation );
+
+ // Update the UI
+ portTypeCombo.setInput( portTypes );
+ portTypeCombo.refresh();
+ if( portTypes.size() > 0 )
+ portTypeCombo.getCombo().select( 0 );
+ portTypeCombo.getCombo().notifyListeners( SWT.Selection, new Event());
+
+ } catch( InvocationTargetException e1 ) {
+ BPELUIPlugin.log( e1 );
+
+ } catch( InterruptedException e1 ) {
+ BPELUIPlugin.log( e1 );
+ }
+ }
+ });
+
+
+ // "Browse" callback
+ browseButton.addSelectionListener( new SelectionListener() {
+ @Override
+ public void widgetSelected( SelectionEvent e ) {
+ widgetDefaultSelected( e );
+ }
+
+ @Override
+ public void widgetDefaultSelected( SelectionEvent e ) {
+ FileDialog dlg = new FileDialog( getShell());
+ dlg.setFilterExtensions( new String[] { "*.wsdl" });
+ dlg.setFilterNames( new String[] { "WSDL (*.wsdl)" });
+ dlg.setText( "Select a service description (WSDL)." );
+
+ String path = dlg.open();
+ if( path != null ) {
+ File f = new File( path );
+ wsdlUrlText.setText( f.toURI().toString());
+ wsdlUrlText.notifyListeners( SWT.FocusOut, new Event());
+ }
+ }
+ });
+
+
+ // Initialize the port type...
+ if( this.portType != null )
+ portTypeCombo.setSelection( new StructuredSelection( this.portType ));
+
+ else if( portTypeCombo.getCombo().getItemCount() > 0 ) {
+ portTypeCombo.getCombo().select( 0 );
+ portTypeCombo.getCombo().notifyListeners( SWT.Selection, new Event());
+ }
+
+
+ // ... and the page's state
+ updateStatus();
+ if( getErrorMessage() != null ) {
+ setPageComplete( false );
+ setErrorMessage( null );
+ }
+ }
+
+
+ /**
+ * Validates the page data and updates the page state in consequence.
+ */
+ private void updateStatus() {
+ String errorMsg = validatePage();
+ setPageComplete( errorMsg == null );
+ setErrorMessage( errorMsg );
+ }
+
+
+ /**
+ * Validates the page data and stores valid values for further use.
+ * @return an error message or null if everything is right
+ */
+ private String validatePage() {
+
+ String errorMsg = null;
+
+ // Validate the page fields
+ if( this.wsdlUrl == null || this.wsdlUrl.trim().length() == 0 )
+ errorMsg = "You must specify the URL of a service description (WSDL).";
+ else if( this.portType == null )
+ errorMsg = "You must select a port type (contract) to implement in the BPEL process.";
+
+ return errorMsg;
+ }
+}
diff --git a/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/wizards/NewBpelFileWizard.java b/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/wizards/NewBpelFileWizard.java
new file mode 100644
index 0000000..4f180e8
--- /dev/null
+++ b/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/wizards/NewBpelFileWizard.java
@@ -0,0 +1,564 @@
+/*******************************************************************************
+ * Copyright (c) 2006 Oracle Corporation and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Oracle Corporation
+ *******************************************************************************/
+
+package org.eclipse.bpel.ui.wizards;
+
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+import java.net.URISyntaxException;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.eclipse.bpel.common.wsdl.importhelpers.WsdlImportHelper;
+import org.eclipse.bpel.common.wsdl.parsers.WsdlParser;
+import org.eclipse.bpel.model.BPELFactory;
+import org.eclipse.bpel.model.BPELPackage;
+import org.eclipse.bpel.model.OnMessage;
+import org.eclipse.bpel.model.PartnerLink;
+import org.eclipse.bpel.model.Pick;
+import org.eclipse.bpel.model.Process;
+import org.eclipse.bpel.model.Reply;
+import org.eclipse.bpel.model.Sequence;
+import org.eclipse.bpel.model.Variable;
+import org.eclipse.bpel.model.partnerlinktype.PartnerLinkType;
+import org.eclipse.bpel.model.partnerlinktype.PartnerlinktypeFactory;
+import org.eclipse.bpel.model.partnerlinktype.PartnerlinktypePackage;
+import org.eclipse.bpel.model.partnerlinktype.Role;
+import org.eclipse.bpel.model.resource.BPELResourceFactoryImpl;
+import org.eclipse.bpel.model.resource.BPELWriter;
+import org.eclipse.bpel.ui.BPELUIPlugin;
+import org.eclipse.bpel.ui.Templates.TemplateResource;
+import org.eclipse.bpel.ui.util.BPELUtil;
+import org.eclipse.bpel.ui.wizards.NewBpelFileFirstPage.BpelCreationMode;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.ui.INewWizard;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.ide.IDE;
+import org.eclipse.ui.wizards.newresource.BasicNewResourceWizard;
+import org.eclipse.wst.wsdl.Definition;
+import org.eclipse.wst.wsdl.Fault;
+import org.eclipse.wst.wsdl.Import;
+import org.eclipse.wst.wsdl.Message;
+import org.eclipse.wst.wsdl.Operation;
+import org.eclipse.wst.wsdl.Part;
+import org.eclipse.wst.wsdl.PortType;
+import org.eclipse.wst.wsdl.WSDLFactory;
+import org.eclipse.wst.wsdl.util.WSDLConstants;
+import org.xml.sax.SAXException;
+
+/**
+ * The creation wizard for a new BPEL process.
+ * @author Michal Chmielewski - Oracle
+ * @author Edwin Khodabakchian - Oracle
+ * @author Vincent Zurczak - EBM WebSourcing
+ */
+public class NewBpelFileWizard extends Wizard implements INewWizard {
+
+ static final String DIALOG_SETTINGS_PROCESS_NAME = "process-name";
+ static final String DIALOG_SETTINGS_PROCESS_TPL_KEY = "process-template-key";
+
+ private IStructuredSelection selection;
+ private IWorkbench fWorkbench;
+
+ private NewBpelFileFirstPage firstPage;
+ private NewBpelFileLocationPage locationPage;
+ private NewBpelFileWsdlPage wsdlPage;
+ private NewBpelFilePortTypePage portTypePage;
+
+
+ /**
+ * Constructor.
+ */
+ public NewBpelFileWizard() {
+ this.setWindowTitle( Messages.NewFileWizard_1 );
+
+ setDialogSettings( BPELUIPlugin.INSTANCE.getDialogSettingsFor( this ));
+ setHelpAvailable( false );
+ setNeedsProgressMonitor( true );
+ }
+
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.IWorkbenchWizard
+ * #init(org.eclipse.ui.IWorkbench, org.eclipse.jface.viewers.IStructuredSelection)
+ */
+ @Override
+ public void init(IWorkbench workbench, IStructuredSelection currentSelection) {
+ this.fWorkbench = workbench;
+ this.selection = currentSelection;
+ }
+
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.wizard.Wizard
+ * #addPages()
+ */
+ @Override
+ public void addPages() {
+
+ this.firstPage = new NewBpelFileFirstPage();
+ this.locationPage = new NewBpelFileLocationPage( this.selection );
+ this.wsdlPage = new NewBpelFileWsdlPage();
+ this.portTypePage = new NewBpelFilePortTypePage();
+
+ // Add all the pages
+ // The pages will then decide which one follows them
+ addPage( this.firstPage );
+ addPage( this.portTypePage );
+ addPage( this.wsdlPage );
+ addPage( this.locationPage );
+ }
+
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.wizard.Wizard
+ * #canFinish()
+ */
+ @Override
+ public boolean canFinish() {
+
+ boolean complete = this.firstPage.isPageComplete() && this.locationPage.isPageComplete();
+ if( complete ) {
+ if( this.firstPage.getCreationMode() == BpelCreationMode.CREATE_NEW_BPEL )
+ complete = this.wsdlPage.isPageComplete();
+ else
+ complete = this.portTypePage.isPageComplete();
+ }
+
+ return complete;
+ }
+
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.wizard.Wizard
+ * #performFinish()
+ */
+ @Override
+ public boolean performFinish() {
+
+ // Prepare the operation
+ IRunnableWithProgress runnable = new IRunnableWithProgress() {
+ @Override
+ public void run( IProgressMonitor monitor )
+ throws InvocationTargetException, InterruptedException {
+
+ try {
+ monitor.beginTask( "Creating the process...", IProgressMonitor.UNKNOWN );
+ if( NewBpelFileWizard.this.firstPage.getCreationMode() == BpelCreationMode.GENERATE_BPEL_FROM_WSDL )
+ createResourcesFromWsdl( monitor );
+ else
+ createResourcesFromTemplate( monitor );
+
+ } catch( IOException e ) {
+ throw new InvocationTargetException( e );
+
+ } catch( CoreException e ) {
+ throw new InvocationTargetException( e );
+
+ } finally {
+ monitor.done();
+ }
+ }
+ };
+
+
+ // Execute it
+ final IFile bpelFile = this.locationPage.getProcessFile();
+ boolean success = true;
+ try {
+ getContainer().run( false, true, runnable );
+
+ } catch( InvocationTargetException e ) {
+ success = true;
+ BPELUIPlugin.log( e );
+
+ } catch( InterruptedException e ) {
+ success = true;
+ BPELUIPlugin.log( e );
+
+ } finally {
+ // Refresh the workspace
+ try {
+ bpelFile.getProject().refreshLocal( IResource.DEPTH_INFINITE, null );
+ } catch( CoreException e ) {
+ BPELUIPlugin.log( e );
+ }
+ }
+
+
+ // Open the file?
+ if( success ) {
+ final IWorkbenchPage page = this.fWorkbench.getActiveWorkbenchWindow().getActivePage();
+ getShell().getDisplay().asyncExec( new Runnable() {
+ @Override
+ public void run() {
+ try {
+ IDE.openEditor( page, bpelFile );
+
+ } catch( PartInitException e ) {
+ BPELUIPlugin.log( e );
+ }
+ }
+ });
+
+ BasicNewResourceWizard.selectAndReveal( bpelFile, page.getWorkbenchWindow());
+ }
+
+ return success;
+ }
+
+
+ /**
+ * Creates a BPEL process and the associated resources from the selected template.
+ * @param monitor a progress monitor
+ * @throws CoreException if a resource fails to be created
+ */
+ private void createResourcesFromTemplate( IProgressMonitor monitor ) throws CoreException {
+
+ Map<String,Object> tplProperties = this.firstPage.getProcessTemplateProperties();
+ tplProperties.putAll( this.wsdlPage.getProcessTemplateProperties());
+
+ List<TemplateResource> tplResources = this.wsdlPage.getSelectedTemplate().getResources();
+ monitor.subTask( Messages.BPELCreateOperation_0 );
+
+ for( TemplateResource tplResource : tplResources ) {
+ String result = tplResource.process( tplProperties );
+ IPath path = new Path( tplResource.getName( tplProperties ));
+ IFile targetFile = this.locationPage.getResourceContainer().getFile( path );
+ if( targetFile.exists())
+ targetFile.setContents( new ByteArrayInputStream( result.getBytes()), true, true, monitor );
+ else
+ targetFile.create( new ByteArrayInputStream( result.getBytes()), true, monitor );
+
+ monitor.worked( 1 );
+ }
+ }
+
+
+ /**
+ * Creates a BPEL process from a WSDL definition.
+ * @param monitor a progress monitor
+ * @throws CoreException if a resource fails to be created
+ * @throws IOException
+ */
+ private void createResourcesFromWsdl( IProgressMonitor monitor ) throws IOException {
+
+ // Import the original WSDL?
+ monitor.subTask( "Processing the original WSDL definition..." );
+ String newWsdlUrl = this.portTypePage.getWsdlUrl();
+ if( this.portTypePage.isImportWsdl()) {
+ File targetDirectory = this.locationPage.getResourceContainer().getLocation().toFile();
+ try {
+ Map<String,File> uriToImportedFile = new WsdlImportHelper().importWsdlOrXsdAndDependencies( targetDirectory, newWsdlUrl );
+ File importedWsdlFile = uriToImportedFile.get( newWsdlUrl );
+ if( importedWsdlFile == null )
+ throw new IOException( "The WSDL file could not be found after import." );
+
+ // The URL to put in the imports is the relative location of the WSDL
+ // with respect to the process (and they are both in the same directory)
+ newWsdlUrl = importedWsdlFile.getName();
+
+ } catch( IllegalArgumentException e ) {
+ throw new IOException( "The WSDL could not be imported in the project.", e );
+
+ } catch( URISyntaxException e ) {
+ throw new IOException( "The WSDL could not be imported in the project.", e );
+
+ } catch( SAXException e ) {
+ throw new IOException( "The WSDL could not be imported in the project.", e );
+
+ } catch( ParserConfigurationException e ) {
+ throw new IOException( "The WSDL could not be imported in the project.", e );
+ }
+ }
+
+ monitor.worked( 2 );
+
+
+ // Prepare the save operations
+ Map<Object,Object> saveOptions = new HashMap<Object,Object> ();
+ saveOptions.put( BPELWriter.SKIP_AUTO_IMPORT, Boolean.TRUE );
+
+ ResourceSet resourceSet = WsdlParser.createBasicResourceSetForWsdl();
+ resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put( "bpel", new BPELResourceFactoryImpl());
+ resourceSet.getPackageRegistry().put( PartnerlinktypePackage.eNS_URI, PartnerlinktypePackage.eINSTANCE );
+ resourceSet.getPackageRegistry().put( BPELPackage.eNS_URI, BPELPackage.eINSTANCE );
+
+
+ // Create the WSDL for the artifacts
+ monitor.subTask( "Generating the WSDL for the artifacts..." );
+ Definition artifactsDefinition = generateWsdlArtifacts( monitor, newWsdlUrl );
+ IFile wsdlFile = this.locationPage.getResourceContainer().getFile( new Path( computeWsdlArtifactsName()));
+ URI emfUri = URI.createPlatformResourceURI( wsdlFile.getFullPath().toString(), true );
+
+ Resource resource = resourceSet.createResource( emfUri );
+ resource.getContents().add( artifactsDefinition );
+ resource.save( saveOptions );
+ monitor.worked( 2 );
+
+
+ // Create the process
+ monitor.subTask( "Generating the BPEL file..." );
+ Process bpelProcess = generateBpelProcess( monitor, artifactsDefinition, newWsdlUrl );
+ emfUri = URI.createPlatformResourceURI( this.locationPage.getProcessFile().getFullPath().toString(), true );
+
+ resource = resourceSet.createResource( emfUri );
+ resource.getContents().add( bpelProcess );
+ resource.save( saveOptions );
+ monitor.worked( 2 );
+ }
+
+
+ /**
+ * Generates a WSDL for the artifacts.
+ * @param monitor a progress monitor
+ * @param newWsdlUrl the URL of the business WSDL (as to put in the import declaration)
+ * @return the created definition (to serialize)
+ */
+ @SuppressWarnings( "unchecked" )
+ private Definition generateWsdlArtifacts( IProgressMonitor monitor, String newWsdlUrl ) {
+
+ PortType portType = this.portTypePage.getPortType();
+ Definition businessDefinition = (Definition) portType.eContainer();
+ Definition artifactsDefinition = WSDLFactory.eINSTANCE.createDefinition();
+ artifactsDefinition.setTargetNamespace( businessDefinition.getTargetNamespace() + "Artifacts" );
+
+ // Hack for the role: we need to define manually the name space prefix for the TNS of the business WSDL
+ artifactsDefinition.getNamespaces().put( "tns", businessDefinition.getTargetNamespace());
+
+ // WSDL import
+ Import wsdlImport = WSDLFactory.eINSTANCE.createImport();
+ wsdlImport.setLocationURI( newWsdlUrl );
+ wsdlImport.setNamespaceURI( businessDefinition.getTargetNamespace());
+ artifactsDefinition.addImport( wsdlImport );
+
+ // Partner Link Type
+ PartnerLinkType plType = PartnerlinktypeFactory.eINSTANCE.createPartnerLinkType();
+ plType.setName( portType.getQName().getLocalPart() + "PLT" );
+
+ Role plRole = PartnerlinktypeFactory.eINSTANCE.createRole();
+ plRole.setName( portType.getQName().getLocalPart() + "Role" );
+ plRole.setPortType( portType );
+
+ plType.getRole().add( plRole );
+ artifactsDefinition.getEExtensibilityElements().add( plType );
+ plType.setEnclosingDefinition( artifactsDefinition );
+
+ return artifactsDefinition;
+ }
+
+
+ /**
+ * Generates a BPEL process.
+ * @param monitor a progress monitor
+ * @param artifactsDefintion the artifacts definition
+ * @param newWsdlUrl the URL of the business WSDL (as to put in the import declaration)
+ * @return the created process (to serialize)
+ */
+ private Process generateBpelProcess( IProgressMonitor monitor, Definition artifactsDefinition, String newWsdlUrl ) {
+
+ PortType portType = this.portTypePage.getPortType();
+ Definition businessDefinition = (Definition) portType.eContainer();
+ String bpelName = this.locationPage.getFileName();
+
+ Process bpelProcess = BPELFactory.eINSTANCE.createProcess();
+ bpelProcess.setName( bpelName );
+ bpelProcess.setTargetNamespace( businessDefinition.getTargetNamespace());
+ bpelProcess.setPartnerLinks( BPELFactory.eINSTANCE.createPartnerLinks());
+ bpelProcess.setVariables( BPELFactory.eINSTANCE.createVariables());
+
+
+ // Import the business definition
+ org.eclipse.bpel.model.Import bpelImport = BPELFactory.eINSTANCE.createImport();
+ bpelImport.setLocation( newWsdlUrl );
+ bpelImport.setNamespace( businessDefinition.getTargetNamespace());
+ bpelImport.setImportType( WSDLConstants.WSDL_NAMESPACE_URI );
+ bpelProcess.getImports().add( bpelImport );
+
+
+ // Import the artifacts definition
+ bpelImport = BPELFactory.eINSTANCE.createImport();
+ bpelImport.setLocation( computeWsdlArtifactsName());
+ bpelImport.setNamespace( businessDefinition.getTargetNamespace() + "Artifacts" );
+ bpelImport.setImportType( WSDLConstants.WSDL_NAMESPACE_URI );
+ bpelProcess.getImports().add( bpelImport );
+
+
+ // Create the main partner link
+ PartnerLink pl = BPELFactory.eINSTANCE.createPartnerLink();
+ for( Object elt : artifactsDefinition.getEExtensibilityElements()) {
+ if( ! ( elt instanceof PartnerLinkType ))
+ continue;
+
+ pl.setPartnerLinkType((PartnerLinkType) elt);
+ pl.setName( "bpelProcessPartner" );
+ pl.setMyRole(((PartnerLinkType) elt).getRole().get( 0 ));
+ bpelProcess.getPartnerLinks().getChildren().add( pl );
+ break;
+ }
+
+
+ // Prepare the flow itself
+ Sequence mainSequence = BPELFactory.eINSTANCE.createSequence();
+ mainSequence.setName( "MainSequence" );
+ bpelProcess.setActivity( mainSequence );
+
+ Pick mainPick = BPELFactory.eINSTANCE.createPick();
+ mainPick.setName( "SwitchInvokedOperation" );
+ mainPick.setCreateInstance( true );
+ mainSequence.getActivities().add( mainPick );
+
+
+ // Create the variables: they are deduced from the port type to "implement"
+ Collection<Definition> definitions = WsdlParser.findAllWsdlDefinitions( businessDefinition );
+ for( Object o : portType.getOperations())
+ addOperationDerivedElements((Operation) o, bpelProcess, mainPick, pl, definitions );
+
+ return bpelProcess;
+ }
+
+
+ /**
+ * Creates the required variables and activities to handle an invocation to this operation.
+ * @param operation the operation
+ * @param bpelProcess the BPEL process
+ * @param mainPick the main pick
+ * @param partnerLink the partner link associated with the various activities
+ * @param definitions all the definitions related to the business interface (in case information should be searched in them)
+ */
+ private void addOperationDerivedElements( Operation operation, Process bpelProcess, Pick mainPick, PartnerLink partnerLink, Collection<Definition> definitions ) {
+
+ String opName = BPELUtil.lowerCaseFirstLetter( operation.getName());
+
+ // Input: create the variable...
+ Variable var = BPELFactory.eINSTANCE.createVariable();
+ var.setName( opName + "Request" );
+ findAndSetVariableXmlType( var, operation.getEInput().getEMessage().getQName(), definitions );
+ bpelProcess.getVariables().getChildren().add( var );
+
+ // ... and add an OnMessage activity
+ OnMessage onMessage = BPELFactory.eINSTANCE.createOnMessage();
+ onMessage.setPartnerLink( partnerLink );
+ onMessage.setVariable( var );
+ onMessage.setOperation( operation );
+ mainPick.getMessages().add( onMessage );
+
+
+ // Output: if it exists...
+ if( operation.getOutput() != null ) {
+
+ // Create the variable...
+ var = BPELFactory.eINSTANCE.createVariable();
+ var.setName( opName + "Response" );
+ findAndSetVariableXmlType( var, operation.getEOutput().getEMessage().getQName(), definitions );
+ bpelProcess.getVariables().getChildren().add( var );
+
+ // And add a Reply activity
+ Reply reply = BPELFactory.eINSTANCE.createReply();
+ reply.setName( "ReplyTo" + BPELUtil.upperCaseFirstLetter( opName ));
+ reply.setVariable( var );
+ reply.setOperation( operation );
+ reply.setPartnerLink( partnerLink );
+ onMessage.setActivity( reply );
+
+ } else {
+ onMessage.setActivity( BPELFactory.eINSTANCE.createEmpty());
+ }
+
+
+ // Faults
+ if( operation.getFaults() != null ) {
+ for( Object oo : operation.getFaults().values()) {
+ Fault fault = (Fault) oo;
+ var = BPELFactory.eINSTANCE.createVariable();
+ var.setName( opName + fault.getName());
+ findAndSetVariableXmlType( var, fault.getEMessage().getQName(), definitions );
+ bpelProcess.getVariables().getChildren().add( var );
+ }
+ }
+ }
+
+
+ /**
+ * Finds and sets the XML type for a variable associated with a given WSDL message.
+ * @param variable the variable whose XML type must be set
+ * @param messageName the name of the WSDL message
+ * @param definitions the list of definitions the message part
+ */
+ private void findAndSetVariableXmlType( Variable variable, QName messageName, Collection<Definition> definitions ) {
+
+ // Find and set the variable's type
+ boolean found = false;
+ boolean processed = false;
+ for( Definition def : definitions ) {
+ for( Object o : def.getEMessages()) {
+ Message msg = (Message) o;
+ if( ! ( messageName.equals( msg.getQName())))
+ continue;
+
+ found = true;
+ if( msg.getEParts().size() == 1 ) {
+ processed = true;
+
+ Part part = (Part) msg.getEParts().get( 0 );
+ if( part.getTypeDefinition() != null )
+ variable.setType( part.getTypeDefinition());
+ else if( part.getElementDeclaration() != null )
+ variable.setXSDElement( part.getElementDeclaration());
+ }
+ }
+ }
+
+
+ // Log possible errors
+ if( ! found )
+ BPELUIPlugin.log( new Exception( "The message " + messageName + " could not be found." ), IStatus.ERROR );
+ else if( ! processed )
+ BPELUIPlugin.log( new Exception( "The message " + messageName + " contains more than 1 part. This case is not supported." ), IStatus.ERROR );
+ else if( variable.getXSDElement() == null && variable.getType() == null )
+ BPELUIPlugin.log( new Exception( "The XML type could not be set for the variable " + variable.getName() + ". Please, report a bug." ), IStatus.ERROR );
+ }
+
+
+ /**
+ * @return the name of the WSDL file for the artifacts
+ */
+ private String computeWsdlArtifactsName() {
+ IPath path = new Path( this.locationPage.getFileName());
+ return path.removeFileExtension().toString() + "Artifacts.wsdl";
+ }
+}
diff --git a/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/wizards/NewBpelFileWsdlPage.java b/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/wizards/NewBpelFileWsdlPage.java
new file mode 100644
index 0000000..5c52a05
--- /dev/null
+++ b/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/wizards/NewBpelFileWsdlPage.java
@@ -0,0 +1,349 @@
+/*******************************************************************************
+ * Copyright (c) 2006 Oracle Corporation and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Oracle Corporation
+ *******************************************************************************/
+
+package org.eclipse.bpel.ui.wizards;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.bpel.ui.BPELUIPlugin;
+import org.eclipse.bpel.ui.IBPELUIConstants;
+import org.eclipse.bpel.ui.Templates;
+import org.eclipse.bpel.ui.Templates.Template;
+import org.eclipse.jface.wizard.IWizardPage;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+
+/**
+ * The page of the wizard to deal with the WSDL to create.
+ * @author Michal Chmielewski - Oracle
+ * @author Bob Brodt - Red Hat
+ * @author Vincent Zurczak - EBM WebSourcing
+ */
+public class NewBpelFileWsdlPage extends WizardPage {
+
+ /**
+ * The page's name, so that it can be referenced from other pages.
+ */
+ public static final String PAGE_NAME = "wsdl-creation-page";
+
+ private static final String SOAP_BINDING = "SOAP";
+ private static final String HTTP_BINDING = "HTTP";
+ private static final String SOAP_NAMESPACE="http://schemas.xmlsoap.org/wsdl/soap/";
+ private static final String HTTP_NAMESPACE="http://schemas.xmlsoap.org/wsdl/http/";
+
+ private String processTemplateName, serviceName, address, binding, portName;
+ private Text serviceNameText, portNameText, addressText;
+ private final Map<String,String> processTemplateProperties;
+
+
+ /**
+ * Constructor.
+ */
+ protected NewBpelFileWsdlPage() {
+ super( PAGE_NAME );
+ this.processTemplateProperties = new HashMap<String,String> ();
+
+ setTitle( Messages.NewFileWizard_WSDLCustomPage_Title );
+ setDescription( Messages.NewFileWizard_WSDLCustomPage_Description );
+ setImageDescriptor( BPELUIPlugin.INSTANCE.getImageDescriptor( IBPELUIConstants.ICON_WIZARD_BANNER ));
+
+ this.binding = SOAP_BINDING;
+ String[] tplNames = BPELUIPlugin.INSTANCE.getTemplates().getTemplateNames();
+ if( tplNames != null && tplNames.length > 0 )
+ this.processTemplateName = tplNames[ 0 ];
+ }
+
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.wizard.WizardPage
+ * #getNextPage()
+ */
+ @Override
+ public IWizardPage getNextPage() {
+
+ // We need to do that since the page order depends on user choices
+ IWizardPage nextPage = getWizard().getPage( NewBpelFileLocationPage.PAGE_NAME );
+ nextPage.setPreviousPage( this );
+ return nextPage;
+ }
+
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.IDialogPage
+ * #createControl(org.eclipse.swt.widgets.Composite)
+ */
+ @Override
+ public void createControl( Composite parent ) {
+
+ // Create the container
+ Composite container = new Composite( parent, SWT.NONE );
+ initializeDialogUnits( parent );
+ container.setLayout( new GridLayout( 2, false ));
+ container.setLayoutData( new GridData( GridData.FILL_BOTH ));
+ setControl( container );
+
+
+ // Create the form
+ Label l = new Label( container, SWT.NONE );
+ l.setText( Messages.NewFileWizardPage1_7 );
+ l.setToolTipText( "The template to use for the creation of the new process" );
+
+ final Combo processTemplateCombo = new Combo( container, SWT.DROP_DOWN | SWT.SIMPLE | SWT.READ_ONLY );
+ processTemplateCombo.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ));
+ processTemplateCombo.setItems( BPELUIPlugin.INSTANCE.getTemplates().getTemplateNames());
+ processTemplateCombo.addSelectionListener( new SelectionListener() {
+ @Override
+ public void widgetSelected( SelectionEvent e ) {
+ widgetDefaultSelected( e );
+ }
+
+ @Override
+ public void widgetDefaultSelected( SelectionEvent e ) {
+ NewBpelFileWsdlPage.this.processTemplateName = processTemplateCombo.getText();
+ refreshTemplateWidgets( processTemplateCombo );
+ updateStatus();
+ }
+ });
+
+
+ // Initialize the remaining stuff
+ processTemplateCombo.select( 0 );
+ processTemplateCombo.notifyListeners( SWT.Selection, new Event());
+
+ if( getErrorMessage() != null ) {
+ setPageComplete( false );
+ setErrorMessage( null );
+ }
+ }
+
+
+ /**
+ * Refreshes the widgets with options for the templates.
+ * @param limit the widget which acts as a limit from which sibling widgets can be removed
+ */
+ private void refreshTemplateWidgets( Control limit ) {
+
+ // Remove the widgets
+ boolean found = false;
+ Composite container = limit.getParent();
+ for( Control c : container.getChildren()) {
+ if( found )
+ c.dispose();
+
+ else if( c.equals( limit ))
+ found = true;
+ }
+
+
+ // Add the widgets: first, the service name
+ Label l = new Label( container, SWT.NONE );
+ l.setText( Messages.NewFileWizard_WSDLCustomPage_ServiceLable );
+
+ this.serviceNameText = new Text( container, SWT.BORDER | SWT.SINGLE );
+ this.serviceNameText.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ));
+ if( this.serviceName != null )
+ this.serviceNameText.setText( this.serviceName );
+
+ this.serviceNameText.addModifyListener( new ModifyListener() {
+ @Override
+ public void modifyText( ModifyEvent e ) {
+ NewBpelFileWsdlPage.this.serviceName = ((Text) e.widget).getText();
+ updateStatus();
+ }
+ });
+
+
+ // Other widgets do not have to be shown for the "empty" template
+ // https://issues.jboss.org/browse/JBIDE-7165
+ Template tpl = getSelectedTemplate();
+ String tplKey = tpl == null ? null : tpl.getKey();
+ if( ! Templates.TEMPLATE_KEY_EMPTY.equals( tplKey )) {
+
+ // The port name
+ l = new Label( container, SWT.NONE );
+ l.setText( Messages.NewFileWizard_WSDLCustomPage_PortLabel );
+
+ this.portNameText = new Text( container, SWT.BORDER | SWT.SINGLE );
+ this.portNameText.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ));
+ if( this.portName != null )
+ this.portNameText.setText( this.portName );
+
+ this.portNameText.addModifyListener( new ModifyListener() {
+ @Override
+ public void modifyText( ModifyEvent e ) {
+ NewBpelFileWsdlPage.this.portName = ((Text) e.widget).getText();
+ updateStatus();
+ }
+ });
+
+
+ // The address
+ l = new Label( container, SWT.NONE );
+ l.setText( Messages.NewFileWizard_WSDLCustomPage_AddressLabel );
+
+ this.addressText = new Text( container, SWT.BORDER | SWT.SINGLE );
+ this.addressText.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ));
+ if( this.address != null )
+ this.addressText.setText( this.address );
+
+ this.addressText.addModifyListener( new ModifyListener() {
+ @Override
+ public void modifyText( ModifyEvent e ) {
+ NewBpelFileWsdlPage.this.address = ((Text) e.widget).getText();
+ updateStatus();
+ }
+ });
+
+
+ // The binding
+ l = new Label( container, SWT.NONE );
+ l.setText( Messages.NewFileWizard_WSDLCustomPage_BindingLabel );
+
+ Combo bindingCombo = new Combo( container, SWT.BORDER | SWT.DROP_DOWN | SWT.SIMPLE | SWT.READ_ONLY );
+ bindingCombo.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ));
+ bindingCombo.setItems( new String[] { SOAP_BINDING, HTTP_BINDING });
+
+ int index = HTTP_BINDING.equals( this.binding ) ? 1 : 0;
+ bindingCombo.select( index );
+ bindingCombo.notifyListeners( SWT.Selection, new Event());
+ bindingCombo.addModifyListener( new ModifyListener() {
+ @Override
+ public void modifyText( ModifyEvent e ) {
+ NewBpelFileWsdlPage.this.binding = ((Combo) e.widget).getText();
+ updateStatus();
+ }
+ });
+ }
+
+
+ // Lay out the parent
+ container.layout();
+ }
+
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.DialogPage
+ * #setVisible(boolean)
+ */
+ @Override
+ public void setVisible( boolean visible ) {
+
+ // Update some fields
+ if( this.serviceNameText != null && ! this.serviceNameText.isDisposed()) {
+ String pName = getWizard().getDialogSettings().get( NewBpelFileWizard.DIALOG_SETTINGS_PROCESS_NAME );
+ if( pName != null ) {
+ this.serviceNameText.setText( pName + "Service" );
+
+ if( this.portNameText != null && ! this.portNameText.isDisposed())
+ this.portNameText.setText( pName + "Port" );
+
+ if( this.addressText != null && ! this.addressText.isDisposed())
+ this.addressText.setText( "http://localhost:8080/" + pName );
+ }
+ }
+
+ // Do the usual work
+ super.setVisible( visible );
+ }
+
+
+ /**
+ * @return the processTemplateProperties
+ */
+ public Map<String, String> getProcessTemplateProperties() {
+ return this.processTemplateProperties;
+ }
+
+
+ /**
+ * @return the selected template or null if no template was selected
+ */
+ public Template getSelectedTemplate() {
+ return this.processTemplateName == null ? null : BPELUIPlugin.INSTANCE.getTemplates().getTemplateByName( this.processTemplateName );
+ }
+
+
+ /**
+ * Validates the page data and updates the page state in consequence.
+ */
+ private void updateStatus() {
+ String errorMsg = validatePage();
+ setPageComplete( errorMsg == null );
+ setErrorMessage( errorMsg );
+ }
+
+
+ /**
+ * Validates the page data and stores valid values for further use.
+ * @return an error message or null if everything is right
+ */
+ private String validatePage() {
+
+ String errorMsg = null;
+
+ // Validate the page fields
+ Template tpl;
+ if(( tpl = getSelectedTemplate()) == null )
+ errorMsg = "The selected template does not match a concrete one."; // Should never happen, but...
+
+ else if( this.serviceName == null || this.serviceName.trim().length() == 0 )
+ errorMsg = "You have to specify the service name.";
+
+ else if( this.serviceName.matches( "\\s" ))
+ errorMsg = "The service name cannot contain spaces or white characters.";
+
+ if( this.portName == null || this.portName.trim().length() == 0 )
+ errorMsg = "You have to specify the port name.";
+
+ else if( this.portName.matches( "\\s" ))
+ errorMsg = "The port name cannot contain spaces or white characters.";
+
+ if( this.address == null || this.address.trim().length() == 0 )
+ errorMsg = "You have to specify the service address.";
+
+ else if( this.address.matches( "\\s" ))
+ errorMsg = "The address cannot contain spaces or white characters.";
+
+ // No error => store properties for the templates
+ if( errorMsg == null ) {
+
+ this.processTemplateProperties.put( Templates.PROPERTY_NAME, this.processTemplateName );
+ this.processTemplateProperties.put( Templates.PROPERTY_KEY, tpl.getKey()); // https://jira.jboss.org/browse/JBIDE-7165
+ this.processTemplateProperties.put( "serviceName", this.serviceName ); //$NON-NLS-1$
+ this.processTemplateProperties.put( "portName", this.portName ); //$NON-NLS-1$
+ this.processTemplateProperties.put( "address", this.address ); //$NON-NLS-1$
+ this.processTemplateProperties.put( "protocol", this.binding.toLowerCase()); //$NON-NLS-1$
+ if( SOAP_BINDING.equals( this.binding ))
+ this.processTemplateProperties.put( "protocolNamespace", SOAP_NAMESPACE );
+ else
+ this.processTemplateProperties.put( "protocolNamespace", HTTP_NAMESPACE );
+ }
+
+ return errorMsg;
+ }
+}
diff --git a/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/wizards/NewFileWizard.java b/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/wizards/NewFileWizard.java
deleted file mode 100644
index 04e799f..0000000
--- a/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/wizards/NewFileWizard.java
+++ /dev/null
@@ -1,266 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 Oracle Corporation and others.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle Corporation
- *******************************************************************************/
-
-package org.eclipse.bpel.ui.wizards;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.Map;
-
-import org.eclipse.bpel.ui.BPELUIPlugin;
-import org.eclipse.bpel.ui.Templates.Template;
-import org.eclipse.bpel.ui.util.BPELUtil;
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.wizard.Wizard;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.INewWizard;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.ide.IDE;
-import org.eclipse.ui.wizards.newresource.BasicNewResourceWizard;
-
-/**
- * Wizard for the new process template.
- *
- * @author Michal Chmielewski (michal.chmielewski@oracle.com)
- *
- */
-
-public class NewFileWizard extends Wizard implements INewWizard {
-
- /** The id of our BPEL editor */
- static protected final String BPEL_EDITOR_ID = "org.eclipse.bpel.ui.bpeleditor"; //$NON-NLS-1$
-
- /** The container where the file(s) will be created */
- private IContainer mContainer;
-
- private IWorkbench fWorkbench;
-
- /** The 1st page of the wizard */
- private NewFileWizardPage1 fMainPage;
-
- /** The 2nd page of the wizard */
- private NewFileWizardPage2 fContainerPage;
-
- /** The 3nd page of the wizard */
- private WSDLCustomPage wsdlPage;
-
- /**
- * Create a brand new shining Create Project Wizard for BPEL.
- */
-
- public NewFileWizard() {
-
- setNeedsProgressMonitor(true);
- setDialogSettings(BPELUIPlugin.INSTANCE.getDialogSettingsFor(this));
- setHelpAvailable(false);
- this.setWindowTitle(Messages.NewFileWizard_1);
-
- }
-
- /**
- * Initialize the wizard object through the normal eclipse initialization
- * mechanism.
- *
- * @param workbench
- * the workbench reference
- * @param currentSelection
- * the current selection reference
- *
- * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench,
- * org.eclipse.jface.viewers.IStructuredSelection)
- */
-
- public void init(IWorkbench workbench, IStructuredSelection currentSelection) {
- fWorkbench = workbench;
- mContainer = getBPELContainer(currentSelection.getFirstElement());
- }
-
- protected void selectAndReveal(IResource newResource) {
- BasicNewResourceWizard.selectAndReveal(newResource, fWorkbench
- .getActiveWorkbenchWindow());
- }
-
- protected void openResource(final IFile resource) {
- if (resource.getType() != IResource.FILE) {
- return;
- }
-
- IWorkbenchWindow window = fWorkbench.getActiveWorkbenchWindow();
- if (window == null) {
- return;
- }
-
- final IWorkbenchPage activePage = window.getActivePage();
- if (activePage != null) {
- final Display display = getShell().getDisplay();
- display.asyncExec(new Runnable() {
- public void run() {
- try {
- IDE.openEditor(activePage, resource, BPEL_EDITOR_ID,
- true);
- // IDE.openEditor(activePage, resource, true);
- } catch (PartInitException e) {
- BPELUIPlugin.log(e);
- }
- }
- });
- BasicNewResourceWizard.selectAndReveal(resource, activePage
- .getWorkbenchWindow());
- }
- }
-
- /**
- * Perform cancel. Close the wizard and don't do anything else.
- *
- * @return true if canceled
- */
- @Override
- public boolean performCancel() {
- return super.performCancel();
- }
-
- /**
- * Add pages to the Open project wizard.
- *
- */
-
- @Override
- public void addPages() {
-
- fMainPage = new NewFileWizardPage1(Messages.NewFileWizardPage1_Name);
- fContainerPage = new NewFileWizardPage2(
- Messages.NewFileWizardPage2_Name);
- wsdlPage = new WSDLCustomPage(
- Messages.NewFileWizard_WSDLCustomPage_Name);
-
- addPage(fMainPage);
- addPage(wsdlPage);
- addPage(fContainerPage);
- wsdlPage.setPreviousPage(fMainPage);
- fContainerPage.setPreviousPage(wsdlPage);
- }
-
- /**
- * Perform the finish operation of the create project wizard.
- *
- * @return true on success, false on failure
- *
- * @see Wizard#performFinish
- */
-
- @Override
- public boolean performFinish() {
-
- BPELCreateOperation runnable = new BPELCreateOperation();
-
- // The container either comes from the 2nd page, explicitely defined
- // or it comes as the context in the current selection.
-
- IContainer container = fContainerPage.getResourceContainer();
- if (container == null) {
- container = mContainer;
- }
-
- runnable.setContainer(container);
- runnable.setTemplate(fMainPage.getSelectedTemplate());
-
- Map<String, Object> map = fMainPage.getArgs();
- map.putAll(wsdlPage.getMap());
- runnable.setArgs(map);
-
- try {
- getContainer().run(false, true, runnable);
- } catch (InvocationTargetException e) {
- BPELUIPlugin.log(e);
- return false;
- } catch (InterruptedException e) {
- BPELUIPlugin.log(e);
- return false;
- }
-
- IFile res = (IFile) runnable.getElementToOpen();
- if (res != null && res.exists()) {
- openResource(res);
- }
- return true;
- }
-
- /**
- * Return the BPEL files container in which we can generate process from the
- * template.
- *
- * @return the BPEL files IContainer
- */
-
- IContainer getBPELContainer(Object obj) {
- if (obj == null) {
- return null;
- }
- IContainer bpelContainer = null;
- IProject project = null;
- if (obj instanceof IFile) {
- IFile file = (IFile) obj;
- project = file.getProject();
- }
- if (obj instanceof IContainer) {
- IContainer container = (IContainer) obj;
- project = container.getProject();
- }
- bpelContainer = BPELUtil.getBPELContentFolder(project);
- if (bpelContainer == null) {
- // https://issues.jboss.org/browse/JBIDE-8591
- // use folder or project
- if (obj instanceof IContainer)
- bpelContainer = (IContainer)obj;
- else
- bpelContainer = project;
- }
- return bpelContainer;
- }
-
- // https://issues.jboss.org/browse/JBIDE-8591
- // added to allow first and last page access to resource container
- public IContainer getBPELContainer() {
- return mContainer;
- }
-
- public void setBPELContainer(IContainer container) {
- mContainer = container;
- }
-
- /**
- * @return the currently selected Template
- * @see https://jira.jboss.org/browse/JBIDE-7165
- */
- public Template getSelectedTemplate()
- {
- return fMainPage.getSelectedTemplate();
- }
-
- /**
- *
- * Final condition for the wizard to finish
- */
-
- @Override
- public boolean canFinish() {
- return (fMainPage.isPageComplete() && wsdlPage.isPageComplete() && fContainerPage.isPageComplete() && mContainer != null)
- || super.canFinish();
- }
-
-}
diff --git a/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/wizards/NewFileWizardPage1.java b/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/wizards/NewFileWizardPage1.java
deleted file mode 100644
index 93498cc..0000000
--- a/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/wizards/NewFileWizardPage1.java
+++ /dev/null
@@ -1,502 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 Oracle Corporation and others.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle Corporation
- *******************************************************************************/
-
-package org.eclipse.bpel.ui.wizards;
-
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.bpel.model.util.BPELConstants;
-import org.eclipse.bpel.ui.BPELUIPlugin;
-import org.eclipse.bpel.ui.IBPELUIConstants;
-import org.eclipse.bpel.ui.Templates;
-import org.eclipse.bpel.ui.Templates.Template;
-import org.eclipse.bpel.ui.util.BPELUtil;
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.jface.dialogs.IDialogSettings;
-import org.eclipse.jface.wizard.IWizardPage;
-import org.eclipse.jface.wizard.WizardPage;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Group;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.internal.ide.IDEWorkbenchPlugin;
-
-/**
- *
- * @author Michal Chmielewski (michal.chmielewski@oracle.com)
- *
- */
-
-@SuppressWarnings("restriction")
-public class NewFileWizardPage1 extends WizardPage {
-
- static final String EMPTY = ""; //$NON-NLS-1$
-
- /** last namespace used in creating a project, saved in dialog settings */
- static final String LAST_NAMESPACE_KEY = "last.namespace.used"; //$NON-NLS-1$
-
- /** Process name field */
- private Text processNameField;
-
- /** which namespace to use to create the process */
- Combo processNamespaceField;
-
- /** which template to use to create a process */
- Combo processTemplateField;
-
- /** Template description, in summary */
- Text templateDescription;
-
- /** option for creating an abstract process */
- Button processAbstractOptionButton;
-
- private Map<String, Object> mArgs = new HashMap<String, Object>(3);
-
- private String[] lastNS;
- private List<String> temNS;
-
- private Listener validateListner = new Listener() {
- public void handleEvent(Event event) {
- setPageComplete(validatePage());
- }
- };
-
- // constants
- private static final int SIZING_TEXT_FIELD_WIDTH = 250;
-
- /**
- * Creates a new project creation wizard page.
- *
- * @param pageName
- * the name of this page
- */
- public NewFileWizardPage1(String pageName) {
- super(pageName);
- setPageComplete(false);
-
- setTitle(Messages.NewFileWizardPage1_2);
- setDescription(Messages.NewFileWizardPage1_3);
-
- setImageDescriptor(BPELUIPlugin.INSTANCE
- .getImageDescriptor(IBPELUIConstants.ICON_WIZARD_BANNER));
- }
-
- /**
- * Method declared on IDialogPage.
- *
- * @param parent
- * the parent composite that we must attach ourselves to
- */
-
- public void createControl(Composite parent) {
- Composite composite = new Composite(parent, SWT.NULL);
- composite.setFont(parent.getFont());
-
- initializeDialogUnits(parent);
-
- composite.setLayout(new GridLayout());
- composite.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- createProjectGroup(composite);
-
- setPageComplete(validatePage());
-
- // no errors on opening up the wizard
- setErrorMessage(null);
- setMessage(null);
- setControl(composite);
-
- // figure out the what needs to go
- }
-
- /**
- * Creates the project name specification controls.
- *
- * @param parent
- * the parent composite
- */
- private final void createProjectGroup(Composite parent) {
- Group projectGroup = new Group(parent, SWT.NONE);
- projectGroup.setText(Messages.NewFileWizardPage1_4);
- projectGroup.setLayout(new GridLayout());
- projectGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- Composite fields = new Composite(projectGroup, SWT.NONE);
- GridLayout layout = new GridLayout();
- layout.numColumns = 2;
- fields.setLayout(layout);
- fields.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- // new project label
- Label projectLabel = new Label(fields, SWT.NONE);
- projectLabel.setText(Messages.NewFileWizardPage1_5);
- projectLabel.setFont(parent.getFont());
-
- // new project name entry field
- processNameField = new Text(fields, SWT.BORDER);
- GridData data = new GridData(GridData.FILL_HORIZONTAL);
- data.widthHint = SIZING_TEXT_FIELD_WIDTH;
- processNameField.setLayoutData(data);
- processNameField.setFont(parent.getFont());
-
- processNameField.addListener(SWT.Modify, validateListner);
-
- // new project label
- Label namespaceLabel = new Label(fields, SWT.NONE);
- namespaceLabel.setText(Messages.NewFileWizardPage1_6);
- namespaceLabel.setFont(parent.getFont());
-
- // new project name entry field
- processNamespaceField = new Combo(fields, SWT.DROP_DOWN | SWT.SIMPLE);
- data = new GridData(GridData.FILL_HORIZONTAL);
- data.widthHint = SIZING_TEXT_FIELD_WIDTH;
- processNamespaceField.setLayoutData(data);
- processNamespaceField.setFont(parent.getFont());
-
- // add the namespace values
- processNamespaceField.setItems(getProcessNameSpaces());
- processNamespaceField.addListener(SWT.Modify, validateListner);
-
- String lastNamespace = null;
- if (lastNS != null) {
- if (lastNS.length > 0) {
- lastNamespace = lastNS[0];
- }
- }
- if (lastNamespace != null) {
- processNamespaceField.setText(lastNamespace);
- }
-
- // new project type
- Label typeLabel = new Label(fields, SWT.NONE);
- typeLabel.setText(Messages.NewFileWizardPage1_7);
- typeLabel.setFont(parent.getFont());
-
- // new project type selector
- processTemplateField = new Combo(fields, SWT.DROP_DOWN | SWT.SIMPLE
- | SWT.READ_ONLY);
- data = new GridData(GridData.FILL_HORIZONTAL);
- data.widthHint = SIZING_TEXT_FIELD_WIDTH;
- processTemplateField.setLayoutData(data);
-
- processTemplateField.addListener(SWT.Modify, new Listener() {
-
- public void handleEvent(Event event) {
- String val = processTemplateField.getText().trim();
- // https://bugs.eclipse.org/bugs/show_bug.cgi?id=330813
- // https://jira.jboss.org/browse/JBIDE-7165
- mArgs.put(Templates.PROPERTY_NAME, val);
- Template template = BPELUIPlugin.INSTANCE.getTemplates()
- .getTemplateByName(val);
- if (template != null) {
- String txt = template.getDescription();
- templateDescription.setText(txt == null ? EMPTY : txt);
- // https://jira.jboss.org/browse/JBIDE-7165
- mArgs.put(Templates.PROPERTY_KEY, template.getKey());
- }
-
- }
- });
-
- templateDescription = new Text(projectGroup, SWT.READ_ONLY | SWT.WRAP
- | SWT.SCROLL_LINE | SWT.V_SCROLL);
- data = new GridData(GridData.FILL_HORIZONTAL);
- data.widthHint = SIZING_TEXT_FIELD_WIDTH;
- data.heightHint = 60;
- templateDescription.setLayoutData(data);
- templateDescription.setFont(parent.getFont());
-
- // Scan directories in the "templates" folder
- // and built up a list
-
- String templates[] = BPELUIPlugin.INSTANCE.getTemplates()
- .getTemplateNames();
- processTemplateField.setItems(templates);
-
- // Select the top one.
- if (templates.length > 0) {
- processTemplateField.select(0);
- }
-
- // add checkbox for abstract process option
- processAbstractOptionButton = new Button(projectGroup, SWT.CHECK);
- processAbstractOptionButton.setText(Messages.NewFileWizardPage1_9);
- processAbstractOptionButton.setFont(parent.getFont());
- processAbstractOptionButton
- .addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent event) {
- setPageComplete(validatePage());
- }
- });
- }
-
- private String[] getProcessNameSpaces() {
- // project specification group
- IDialogSettings settings = getWizard().getDialogSettings();
- String ns = settings.get(LAST_NAMESPACE_KEY);
- ArrayList<String> list = new ArrayList<String>();
- if (ns != null && !"".equals(ns)) {
- lastNS = ns.split(";");
- for (String str : lastNS) {
- list.add(str);
- }
- }
- temNS = new ArrayList<String>();
- for (String str : BPELUIPlugin.INSTANCE.getTemplates()
- .getNamespaceNames()) {
- temNS.add(str);
- }
- list.addAll(temNS);
- String[] a = new String[(lastNS == null ? 0 : lastNS.length)
- + temNS.size()];
- return list.toArray(a);
- }
-
- /**
- * Returns the current project name as entered by the user, or its
- * anticipated initial value.
- *
- * @return the project name, its anticipated initial value, or
- * <code>null</code> if no project name is known
- */
- public String getProjectName() {
- return getProjectNameFieldValue();
- }
-
- /**
- * Returns the value of the project name field with leading and trailing
- * spaces removed.
- *
- * @return the project name in the field
- */
- private String getProjectNameFieldValue() {
-
- if (processNameField == null) {
- return EMPTY;
- }
- return processNameField.getText().trim();
- }
-
- /**
- * Returns the current project name as entered by the user, or its
- * anticipated initial value.
- *
- * @return the project name, its anticipated initial value, or
- * <code>null</code> if no project name is known
- */
- public String getProjectNamespace() {
-
- return getProjectNamespaceFieldValue();
- }
-
- /**
- * Returns the value of the project name field with leading and trailing
- * spaces removed.
- *
- * @return the project name in the field
- */
- private String getProjectNamespaceFieldValue() {
- if (processNameField == null) {
- return EMPTY;
- }
- return processNamespaceField.getText().trim();
- }
-
- /**
- * Returns whether this page's controls currently all contain valid values.
- *
- * @return <code>true</code> if all controls are valid, and
- * <code>false</code> if at least one is invalid
- */
- protected boolean validatePage() {
-
- IWorkspace workspace = IDEWorkbenchPlugin.getPluginWorkspace();
-
- IDialogSettings settings = getWizard().getDialogSettings();
-
- String processName = processNameField.getText();
-
- if (processName.equals(EMPTY)) {
- setErrorMessage(null);
- setMessage(Messages.NewFileWizardPage1_8);
- return false;
- }
-
- IStatus nameStatus = workspace
- .validateName(processName, IResource.FILE);
-
- if (!nameStatus.isOK()) {
- setErrorMessage(nameStatus.getMessage());
- return false;
- }
-
- // Make sure that there are no spaces in the name
- if (processName.indexOf(" ") > -1) //$NON-NLS-1$
- {
- setErrorMessage(Messages.NewFileWizardPage1_10);
- return false;
- }
-
- setErrorMessage(null);
- setMessage(null);
-
- // https://issues.jboss.org/browse/JBIDE-8591
- NewFileWizard wiz = (NewFileWizard)getWizard();
- // https://issues.jboss.org/browse/JBIDE-8738
- IContainer container = wiz.getBPELContainer();
- if (container!=null) {
- if (!BPELUtil.isBPELProject(container.getProject()))
- setMessage(Messages.NewFileWizard_Not_A_BPELFaceted_Project, WizardPage.WARNING);
-
- if (container.findMember(processNameField.getText()+".bpel")!=null ) //$NON-NLS-1$
- setMessage(Messages.NewFileWizardPage1_12,WARNING);
- }
-
- String namespace = processNamespaceField.getText().trim();
- if (namespace.length() < 1) {
- setErrorMessage(Messages.NewFileWizardPage1_11);
- return false;
- }
-
- String bpelNamespace = (isAbstractOptionButtonChecked()) ? BPELConstants.NAMESPACE_ABSTRACT_2007
- : BPELConstants.NAMESPACE;
-
- // settings for next time the dialog is used.
- settings.put(LAST_NAMESPACE_KEY, addNSToDefault(namespace));
-
- // Template arguments
- mArgs.put("processName", processName); //$NON-NLS-1$
- mArgs.put("namespace", namespace); //$NON-NLS-1$
- mArgs.put("bpelNamespace", bpelNamespace); //$NON-NLS-1$
- mArgs.put("date", new Date()); //$NON-NLS-1$
-
- // set the default value of the wsdlpage
- setValuesForWSDLPage(processName);
-
- return true;
- }
-
- private void setValuesForWSDLPage(String processName) {
- WSDLCustomPage page = (WSDLCustomPage) this.getWizard().getPage(
- Messages.NewFileWizard_WSDLCustomPage_Name);
- if (page != null) {
- page.getServiceNameField().setText(processName);
- page.getPortNameField().setText(processName + "Port");
- page.getAddressField().setText(
- "http://localhost:8080/" + processName);
- }
- NewFileWizardPage2 page2 = (NewFileWizardPage2) this.getWizard().getPage(
- Messages.NewFileWizardPage2_Name);
- if (page2 != null) {
- page2.setProcessName(processName);
- }
- }
-
- public IWizardPage getNextPage() {
- if (processAbstractOptionButton.getSelection()) {
- return this.getWizard().getPage(Messages.NewFileWizardPage2_Name);
- }
- return super.getNextPage();
- }
-
- /**
- * add the last namespace to the default namespace array
- *
- * @param namespace
- * @return
- */
- private String addNSToDefault(String namespace) {
- StringBuffer ns = new StringBuffer();
- if (!"".equals(namespace) && !temNS.contains(namespace)) {
- ns.append(namespace).append(";");
- ;
- if (lastNS != null) {
- for (int i = 0; i < lastNS.length; i++) {
- if (namespace.equals(lastNS[i])) {
- continue;
- } else {
- ns.append(lastNS[i]).append(";");
- if (i > 8) {
- break;
- }
- }
- }
- }
- } else {
- if (lastNS != null) {
- for (String str : lastNS) {
- ns.append(str).append(";");
- }
- }
- }
- return ns.toString();
- }
-
- /**
- * @return true if Option for abstract process is checked
- */
- private boolean isAbstractOptionButtonChecked() {
- return processAbstractOptionButton.getSelection();
- }
-
- /**
- * see @DialogPage.setVisible(boolean)
- *
- * @param visible
- * whether should be visible or not
- *
- */
-
- @Override
- public void setVisible(boolean visible) {
- super.setVisible(visible);
- if (visible) {
- processNameField.setFocus();
- // https://issues.jboss.org/browse/JBIDE-8591
- validatePage();
- }
- }
-
- /**
- * @return the actual selected template.
- */
-
- public Template getSelectedTemplate() {
- String txt = processTemplateField.getText().trim();
- return BPELUIPlugin.INSTANCE.getTemplates().getTemplateByName(txt);
- }
-
- /**
- * @return the arguments that need to be supplied to the template mechanism.
- */
-
- public Map<String, Object> getArgs() {
-
- return mArgs;
- }
-}
diff --git a/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/wizards/NewFileWizardPage2.java b/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/wizards/NewFileWizardPage2.java
deleted file mode 100644
index b3cad1e..0000000
--- a/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/wizards/NewFileWizardPage2.java
+++ /dev/null
@@ -1,143 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 Oracle Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.bpel.ui.wizards;
-
-import org.eclipse.bpel.ui.BPELUIPlugin;
-import org.eclipse.bpel.ui.IBPELUIConstants;
-import org.eclipse.bpel.ui.util.BPELUtil;
-import org.eclipse.bpel.ui.util.filedialog.FileSelectionGroup;
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.jface.wizard.WizardPage;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Listener;
-
-/**
- * @author Michal Chmielewski (michal.chmielewski@oracle.com)
- * @date Jul 20, 2006
- *
- */
-public class NewFileWizardPage2 extends WizardPage {
-
- private FileSelectionGroup fResourceComposite;
- private String processName;
-
- /**
- * New File Wizard, page 2.
- *
- * @param pageName
- */
-
- public NewFileWizardPage2(String pageName)
- {
- super(pageName);
- setPageComplete(false);
-
- setTitle(Messages.NewFileWizardPage2_3);
- setDescription(Messages.NewFileWizardPage2_0);
-
- setImageDescriptor( BPELUIPlugin.INSTANCE.getImageDescriptor( IBPELUIConstants.ICON_WIZARD_BANNER ));
- }
-
- /** (non-Javadoc)
- * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
- */
- public void createControl (Composite parent) {
-
- final NewFileWizard wiz = (NewFileWizard) getWizard();
- Composite composite = new Composite(parent, SWT.NULL);
-
- initializeDialogUnits(parent);
-
- composite.setLayout(new GridLayout());
- composite.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- // Start Resource Variant
- fResourceComposite = new FileSelectionGroup(composite,
- new Listener() {
- public void handleEvent(Event event) {
- IResource resource = fResourceComposite.getSelectedResource();
- setPageComplete(validatePage(resource));
- if (resource instanceof IContainer)
- wiz.setBPELContainer((IContainer)resource);
- }
- },
- Messages.NewFileWizardPage2_1,
- Messages.NewFileWizardPage2_2);
- // https://issues.jboss.org/browse/JBIDE-8591
- // update wizard so first page gets the new resource location
- fResourceComposite.setSelectedResource(wiz.getBPELContainer());
- setControl(composite);
- }
-
- private boolean validatePage(IResource resource){
- if (resource instanceof IContainer) {
- IContainer container = (IContainer)resource;
- // https://issues.jboss.org/browse/JBIDE-8591
-
- if ( container.findMember(processName +".bpel") != null ) { //$NON-NLS-1$
- setMessage(Messages.NewFileWizardPage1_12, WizardPage.ERROR);
- return false;
- }
-
- if (!BPELUtil.isBPELProject(resource.getProject())) {
- setMessage(Messages.NewFileWizard_Not_A_BPELFaceted_Project, WizardPage.WARNING);
- return true;
- }
-
- if (!container.equals(BPELUtil.getBPELContentFolder(container.getProject()))) {
- setMessage(Messages.NewFileWizard_Not_A_BPELContent_Folder, WizardPage.WARNING);
- return true;
- }
-
- setMessage(null);
- return true;
- }
- return false;
- }
-
- /**
- * Return the selected resource container for the BPEL project.
- * @return the resource container.
- */
-
- public IContainer getResourceContainer () {
- IResource resource = fResourceComposite.getSelectedResource();
- if (resource != null && resource instanceof IContainer) {
- return (IContainer) resource;
- }
- return null;
- }
-
- public void setProcessName(String processName) {
- this.processName = processName;
- }
-
- @Override
- public boolean isPageComplete() {
-
- IContainer container = getResourceContainer();
- if (container==null)
- return false;
-
- if ( container.findMember(processName +".bpel") != null ) //$NON-NLS-1$
- return false;
-
- if (!super.isPageComplete())
- return false;
-
- return true;
- }
-}
diff --git a/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/wizards/WSDLCustomPage.java b/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/wizards/WSDLCustomPage.java
deleted file mode 100644
index 9b7019e..0000000
--- a/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/wizards/WSDLCustomPage.java
+++ /dev/null
@@ -1,260 +0,0 @@
-package org.eclipse.bpel.ui.wizards;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.bpel.ui.BPELUIPlugin;
-import org.eclipse.bpel.ui.IBPELUIConstants;
-import org.eclipse.bpel.ui.Templates;
-import org.eclipse.bpel.ui.Templates.Template;
-import org.eclipse.jface.wizard.WizardPage;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Group;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.swt.widgets.Text;
-
-public class WSDLCustomPage extends WizardPage {
-
- /** Service name field */
- private Text serviceNameField;
-
- // https://bugs.eclipse.org/bugs/show_bug.cgi?id=330813
- // https://jira.jboss.org/browse/JBIDE-7165
- // make labels class variables so we can hide them for the "Empty" template
- /** Port name field */
- private Label portNameLabel;
- private Text portNameField;
-
- /** Address name field */
- private Label addressLabel;
- private Text addressField;
-
- /** binding protocol */
- private Label bindingLabel;
- private Combo bindingField;
-
- private Map<String, String> mArgs = new HashMap<String, String>();
-
- static final String EMPTY = "";
- static final String SOAP_NAMESPACE="http://schemas.xmlsoap.org/wsdl/soap/";
- static final String HTTP_NAMESPACE="http://schemas.xmlsoap.org/wsdl/http/";
-
- private static final int SIZING_TEXT_FIELD_WIDTH = 250;
-
- private Listener validateListner = new Listener() {
- public void handleEvent(Event event) {
- setPageComplete(validatePage());
- }
- };
-
- /**
- * New File Wizard,wsdl page that custom the generated wsdl file
- *
- * @param pageName
- */
- protected WSDLCustomPage(String pageName) {
- super(pageName);
- setTitle(Messages.NewFileWizard_WSDLCustomPage_Title);
- setDescription(Messages.NewFileWizard_WSDLCustomPage_Description);
- setImageDescriptor(BPELUIPlugin.INSTANCE
- .getImageDescriptor(IBPELUIConstants.ICON_WIZARD_BANNER));
- }
-
- public void createControl(Composite parent) {
- Composite composite = new Composite(parent, SWT.NULL);
- composite.setFont(parent.getFont());
- initializeDialogUnits(parent);
- composite.setLayout(new GridLayout());
- composite.setLayoutData(new GridData(GridData.FILL_BOTH));
- createWSDLGroup(composite);
- setErrorMessage(null);
- setMessage(null);
- setControl(composite);
- }
-
- private final void createWSDLGroup(Composite parent) {
- Group wsdlGroup = new Group(parent, SWT.NONE);
- wsdlGroup.setText(Messages.NewFileWizard_WSDLCustomPage_WSDLGroup);
- wsdlGroup.setLayout(new GridLayout());
- wsdlGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- Composite fields = new Composite(wsdlGroup, SWT.NONE);
- GridLayout layout = new GridLayout();
- layout.numColumns = 2;
- fields.setLayout(layout);
- fields.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- // new service label
- Label serviceLabel = new Label(fields, SWT.NONE);
- serviceLabel
- .setText(Messages.NewFileWizard_WSDLCustomPage_ServiceLable);
- serviceLabel.setFont(parent.getFont());
-
- // new service name entry field
- serviceNameField = new Text(fields, SWT.BORDER);
- GridData data = new GridData(GridData.FILL_HORIZONTAL);
- data.widthHint = SIZING_TEXT_FIELD_WIDTH;
- serviceNameField.setLayoutData(data);
- serviceNameField.setFont(parent.getFont());
- serviceNameField.addListener(SWT.Modify, validateListner);
-
- // new port label
- portNameLabel = new Label(fields, SWT.NONE);
- portNameLabel.setText(Messages.NewFileWizard_WSDLCustomPage_PortLabel);
- portNameLabel.setFont(parent.getFont());
-
- // new port name entry field
- portNameField = new Text(fields, SWT.BORDER);
- data = new GridData(GridData.FILL_HORIZONTAL);
- data.widthHint = SIZING_TEXT_FIELD_WIDTH;
- portNameField.setLayoutData(data);
- portNameField.setFont(parent.getFont());
- portNameField.addListener(SWT.Modify, validateListner);
-
- // new address label
- addressLabel = new Label(fields, SWT.NONE);
- addressLabel
- .setText(Messages.NewFileWizard_WSDLCustomPage_AddressLabel);
- addressLabel.setFont(parent.getFont());
-
- // new address name entry field
- addressField = new Text(fields, SWT.BORDER);
- data = new GridData(GridData.FILL_HORIZONTAL);
- data.widthHint = SIZING_TEXT_FIELD_WIDTH;
- addressField.setLayoutData(data);
- addressField.setFont(parent.getFont());
- addressField.addListener(SWT.Modify, validateListner);
-
- bindingLabel = new Label(fields, SWT.NONE);
- bindingLabel
- .setText(Messages.NewFileWizard_WSDLCustomPage_BindingLabel);
- bindingLabel.setFont(parent.getFont());
- // new binding protocol entry field
- bindingField = new Combo(fields, SWT.DROP_DOWN | SWT.SIMPLE);
- data = new GridData(GridData.FILL_HORIZONTAL);
- data.widthHint = SIZING_TEXT_FIELD_WIDTH;
- bindingField.setLayoutData(data);
- bindingField.setFont(parent.getFont());
-
- // add the binding protocol values
- bindingField.setItems(new String[] { "SOAP", "HTTP" });
- bindingField.setText("SOAP");
- bindingField.addListener(SWT.Modify, validateListner);
- }
-
- // https://bugs.eclipse.org/bugs/show_bug.cgi?id=330813
- // https://jira.jboss.org/browse/JBIDE-7165
- // show or hide additional WSDL parameters depending on whether the template is the "Empty"
- @Override
- public void setVisible(boolean visible) {
- // TODO Auto-generated method stub
- super.setVisible(visible);
- Template template = ((NewFileWizard)getWizard()).getSelectedTemplate();
- if ( template==null || Templates.TEMPLATE_KEY_EMPTY.equals(template.getKey()) ) {
- // this is an Empty BPEL process, so no ports or bindings will be generated.
- // Hide the Port Name, Service Address and Binding controls
- portNameLabel.setVisible(false);
- portNameField.setVisible(false);
-
- addressLabel.setVisible(false);
- addressField.setVisible(false);
-
- bindingLabel.setVisible(false);
- bindingField.setVisible(false);
- }
- else {
- portNameLabel.setVisible(true);
- portNameField.setVisible(true);
-
- addressLabel.setVisible(true);
- addressField.setVisible(true);
-
- bindingLabel.setVisible(true);
- bindingField.setVisible(true);
- }
- }
-
- protected boolean validatePage() {
- setErrorMessage(null);
-
- String serviceName = serviceNameField.getText().trim();
- if (isEmptyOrSpace(serviceName, "Service Name")) {
- return false;
- }
-
- // https://bugs.eclipse.org/bugs/show_bug.cgi?id=330813
- // https://jira.jboss.org/browse/JBIDE-7165
- Template template = ((NewFileWizard)getWizard()).getSelectedTemplate();
- if ( template!=null && !Templates.TEMPLATE_KEY_EMPTY.equals(template.getKey()) ) {
- String portName = portNameField.getText().trim();
- if (isEmptyOrSpace(portName, "Port Name")) {
- return false;
- }
- String addressName = addressField.getText().trim();
- if (isEmptyOrSpace(addressName, "Service Address")) {
- return false;
- }
- String protocol = bindingField.getText().trim();
- if (!("SOAP".equals(protocol) || "HTTP".equals(protocol))) {
- setErrorMessage(Messages.Error_NewFileWizard_WSDLCustomPage_Protocol);
- return false;
- }
-
- // Template arguments
- mArgs.put("portName", portName); //$NON-NLS-1$
- mArgs.put("address", addressName); //$NON-NLS-1$
- mArgs.put("protocol", protocol.toLowerCase()); //$NON-NLS-1$
- if("SOAP".equals(protocol)){
- mArgs.put("protocolNamespace", SOAP_NAMESPACE);
- } else {
- mArgs.put("protocolNamespace", HTTP_NAMESPACE);
- }
- }
-
- // Template arguments
- mArgs.put("serviceName", serviceName); //$NON-NLS-1$
-
- return true;
- }
-
- private boolean isEmptyOrSpace(String name, String element) {
- if (name.equals(EMPTY)) {
- setErrorMessage(NLS.bind(
- Messages.Error_NewFileWizard_WSDLCustomPage_Name_Empty,
- element));
- return true;
- }
-
- if (name.indexOf(" ") > -1) {
- setErrorMessage(NLS.bind(
- Messages.Error_NewFileWizard_WSDLCustomPage_Name_Space,
- element));
- return true;
- }
- return false;
- }
-
- public Text getServiceNameField() {
- return serviceNameField;
- }
-
- public Text getPortNameField() {
- return portNameField;
- }
-
- public Text getAddressField() {
- return addressField;
- }
-
- public Map<String, String> getMap() {
- return mArgs;
- }
-
-}
diff --git a/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/wizards/messages.properties b/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/wizards/messages.properties
index 76c0f91..dd74902 100644
--- a/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/wizards/messages.properties
+++ b/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/wizards/messages.properties
@@ -3,12 +3,11 @@
NewFileWizardPage1_2=Create a BPEL Process File
NewFileWizardPage1_3=Create a 2.0 BPEL file.
NewFileWizardPage1_4=Process Details
-NewFileWizardPage1_5=BPEL Process Name:
+NewFileWizardPage1_5=Process Name:
NewFileWizardPage1_6=Namespace:
NewFileWizardPage1_7=Template:
NewFileWizardPage1_8=Specify the name of this BPEL file.
NewFileWizardPage1_9=Abstract Process
-NewFileWizardPage2_Name=LocationPage
NewFileWizardPage2_0=Select location for the BPEL source files.
NewFileWizardPage2_1=Select Project or Folder for the BPEL files.
NewFileWizardPage2_2=
@@ -20,10 +19,10 @@
NewFileWizard_WSDLCustomPage_Title=Create a WSDL File
NewFileWizard_WSDLCustomPage_Description=Create a WSDL File for the BPEL Process
NewFileWizard_WSDLCustomPage_WSDLGroup=WSDL Details
-NewFileWizard_WSDLCustomPage_ServiceLable=Service Name
-NewFileWizard_WSDLCustomPage_PortLabel=Port Name
-NewFileWizard_WSDLCustomPage_AddressLabel=Service Address
-NewFileWizard_WSDLCustomPage_BindingLabel=Binding Protocol
+NewFileWizard_WSDLCustomPage_ServiceLable=Service Name:
+NewFileWizard_WSDLCustomPage_PortLabel=Port Name:
+NewFileWizard_WSDLCustomPage_AddressLabel=Service Address:
+NewFileWizard_WSDLCustomPage_BindingLabel=Binding Protocol:
NewFileWizard_Not_A_BPELFaceted_Project=The selected location is not a BPEL project.
NewFileWizard_Not_A_BPELContent_Folder=The selected location is not a BPEL Content folder.
Error_NewFileWizard_WSDLCustomPage_Name_Empty=Specify a {0} for the BPEL process in the WSDL file.
diff --git a/plugins/org.eclipse.bpel.validator/src/org/eclipse/bpel/validator/rules/ProcessValidator.java b/plugins/org.eclipse.bpel.validator/src/org/eclipse/bpel/validator/rules/ProcessValidator.java
index 56b41ed..b4d75fb 100644
--- a/plugins/org.eclipse.bpel.validator/src/org/eclipse/bpel/validator/rules/ProcessValidator.java
+++ b/plugins/org.eclipse.bpel.validator/src/org/eclipse/bpel/validator/rules/ProcessValidator.java
@@ -20,29 +20,22 @@
import java.util.LinkedList;
import java.util.List;
-import javax.xml.namespace.QName;
-
import org.eclipse.bpel.model.Import;
import org.eclipse.bpel.model.Process;
-import org.eclipse.bpel.validator.helpers.DOMNodeAdapter;
+import org.eclipse.bpel.validator.model.ARule;
import org.eclipse.bpel.validator.model.Filters;
import org.eclipse.bpel.validator.model.IConstants;
import org.eclipse.bpel.validator.model.IModelQueryLookups;
import org.eclipse.bpel.validator.model.INode;
import org.eclipse.bpel.validator.model.IProblem;
-import org.eclipse.bpel.validator.model.ARule;
import org.eclipse.bpel.validator.model.NodeAttributeValueFilter;
-import org.eclipse.emf.ecore.EObject;
-import org.w3c.dom.Element;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
/**
* Validates Process nodes.
- *
- *
+ *
+ *
* @author Michal Chmielewski (michal.chmielewski@oracle.com)
* @date Sep 14, 2006
*
@@ -52,117 +45,117 @@
@SuppressWarnings({"nls","boxing"})
public class ProcessValidator extends CValidator {
-
+
String ncName ;
-
+
protected String fExitStandardFault;
protected String fSupressJoinFailure;
-
+
protected List<INode> fStartActivities ;
-
- /**
+
+ /**
* Start the validation pass.
- *
- *
+ *
+ *
* @see org.eclipse.bpel.validator.model.Validator#start()
*/
-
+
@Override
protected void start () {
super.start();
-
- ncName = mNode.getAttribute( AT_NAME );
- fTypeToCheckList = new LinkedList<INode>();
- fStartActivities = new ArrayList<INode>();
- setValue ("types.to.check",fTypeToCheckList);
- setValue ("start.activities", fStartActivities);
+
+ this.ncName = this.mNode.getAttribute( AT_NAME );
+ this.fTypeToCheckList = new LinkedList<INode>();
+ this.fStartActivities = new ArrayList<INode>();
+ setValue ("types.to.check",this.fTypeToCheckList);
+ setValue ("start.activities", this.fStartActivities);
}
-
+
/**
- * Rule to check the name of the process.
+ * Rule to check the name of the process.
*/
-
+
@ARule(
- date = "9/14/2006",
+ date = "9/14/2006",
desc = "Rule to check the name of the process",
author = "michal.chmielewski@oracle.com",
errors="BPELC__UNSET_ATTRIBUTE,General.NCName_Bad"
- )
-
- public void rule_CheckName_1 () {
- checkNCName(mNode, ncName, AT_NAME );
+ )
+
+ public void rule_CheckName_1 () {
+ checkNCName(this.mNode, this.ncName, AT_NAME );
}
-
-
-
+
+
+
/**
- * Check if the expression language is acceptable by the model.
+ * Check if the expression language is acceptable by the model.
*/
-
+
@ARule(
author = "michal.chmielewski@oracle.com",
- desc = "Checks the expression language for support in the BPEL model",
+ desc = "Checks the expression language for support in the BPEL model",
date = "9/14/2006",
sa = 4 ,
errors="BPELC__UNSUPPORTED_XML_LANG"
)
-
+
public void rule_CheckExpressionLanguage_3 () {
- String value = mNode.getAttribute( AT_EXPRESSIONLANGUAGE );
+ String value = this.mNode.getAttribute( AT_EXPRESSIONLANGUAGE );
IProblem problem;
-
+
if ( isEmpty(value) ) {
value = IConstants.XMLNS_XPATH_EXPRESSION_LANGUAGE ;
}
setValue(AT_EXPRESSIONLANGUAGE, value);
-
+
// Expression language not supported.
- if (mModelQuery.hasSupport(IModelQueryLookups.SUPPORT_EXPRESSION_LANGUAGE, value) == false) {
+ if (this.mModelQuery.hasSupport(IModelQueryLookups.SUPPORT_EXPRESSION_LANGUAGE, value) == false) {
problem = createError();
problem.fill( "BPELC__UNSUPPORTED_XML_LANG", //$NON-NLS-1$
AT_EXPRESSIONLANGUAGE,value);
- }
-
+ }
+
setValue (AT_EXPRESSIONLANGUAGE,value);
}
-
-
+
+
/**
* Check if the query language is supported by the BPEL model.
*
*/
-
+
@ARule(
author = "michal.chmielewski@oracle.com",
- desc = "Checks the query language for support in the BPEL model",
+ desc = "Checks the query language for support in the BPEL model",
date = "9/14/2006",
sa = 4 ,
errors="BPELC__UNSUPPORTED_XML_LANG"
)
-
+
public void rule_CheckQueryLanguage_4 () {
- String value = mNode.getAttribute( AT_QUERYLANGUAGE );
-
- if ( isEmpty(value) ) {
+ String value = this.mNode.getAttribute( AT_QUERYLANGUAGE );
+
+ if ( isEmpty(value) ) {
value = IConstants.XMLNS_XPATH_EXPRESSION_LANGUAGE;
}
-
+
setValue (AT_QUERYLANGUAGE, value);
-
+
IProblem problem;
// Expression language not supported.
- if (mModelQuery.hasSupport(IModelQueryLookups.SUPPORT_QUERY_LANGUAGE, value) == false) {
+ if (this.mModelQuery.hasSupport(IModelQueryLookups.SUPPORT_QUERY_LANGUAGE, value) == false) {
problem = createError();
problem.fill( "BPELC__UNSUPPORTED_XML_LANG", //$NON-NLS-1$
AT_QUERYLANGUAGE,value);
- }
-
+ }
+
}
-
+
/**
* Check exit on standard fault
@@ -175,24 +168,24 @@
date = "01/10/2007",
errors="BPELC__UNSET_ATTRIBUTE,BPELC__INVALID_ATTRIBUTE_VALUE"
)
-
+
public void rule_CheckExitOnStandardFault_10 () {
-
- fExitStandardFault = getAttribute(mNode,
- AT_EXIT_ON_STANDARD_FAULT,
- KIND_NODE,
- Filters.BOOLEAN_FILTER,
+
+ this.fExitStandardFault = getAttribute(this.mNode,
+ AT_EXIT_ON_STANDARD_FAULT,
+ KIND_NODE,
+ Filters.BOOLEAN_FILTER,
false);
-
- if (isEmpty(fExitStandardFault)) {
- fExitStandardFault = NO;
- }
-
- setValue(AT_EXIT_ON_STANDARD_FAULT,fExitStandardFault);
- }
-
+
+ if (isEmpty(this.fExitStandardFault)) {
+ this.fExitStandardFault = NO;
+ }
+
+ setValue(AT_EXIT_ON_STANDARD_FAULT,this.fExitStandardFault);
+ }
+
/**
- *
+ *
*/
@ARule(
sa = 0,
@@ -200,27 +193,27 @@
author = "michal.chmielewski@oracle.com",
date = "01/10/2007",
errors="BPELC__UNSET_ATTRIBUTE,BPELC__INVALID_ATTRIBUTE_VALUE"
- )
+ )
public void rule_CheckSuppressJoinFailre_11 () {
- fSupressJoinFailure = getAttribute(mNode,
- AT_SUPPRESS_JOIN_FAILURE,
- KIND_NODE,
- Filters.BOOLEAN_FILTER,
+ this.fSupressJoinFailure = getAttribute(this.mNode,
+ AT_SUPPRESS_JOIN_FAILURE,
+ KIND_NODE,
+ Filters.BOOLEAN_FILTER,
false);
-
- if (isEmpty(fSupressJoinFailure)) {
- fSupressJoinFailure = NO;
+
+ if (isEmpty(this.fSupressJoinFailure)) {
+ this.fSupressJoinFailure = NO;
}
- setValue (AT_SUPPRESS_JOIN_FAILURE,fSupressJoinFailure);
-
+ setValue (AT_SUPPRESS_JOIN_FAILURE,this.fSupressJoinFailure);
+
}
-
-
-
+
+
+
/**
* Check if process has start activity.
*/
-
+
@ARule(
sa = 15,
@@ -231,23 +224,23 @@
order = 1000 ,
errors="BPELC_PROCESS__NO_START"
)
-
+
public void CheckIfProcessHasStartActivity () {
-
- if (fStartActivities.size() > 0) {
+
+ if (this.fStartActivities.size() > 0) {
return ;
}
-
+
IProblem problem = createError();
problem.fill("BPELC_PROCESS__NO_START",
- toString(mNode.nodeName()),
- mNode.getAttribute(AT_NAME)
+ toString(this.mNode.nodeName()),
+ this.mNode.getAttribute(AT_NAME)
);
}
-
+
/**
- *
+ *
*/
@ARule(
sa = 57,
@@ -260,98 +253,98 @@
)
public void CheckCorrelationSetsOnStartActivities () {
// if 0 or 1, then it does not matter ...
- if (fStartActivities.size() < 2) {
+ if (this.fStartActivities.size() < 2) {
return ;
- }
-
+ }
+
/** Compute the common correlation sets (intersection) */
-
+
List<INode> commonSets = null;
-
- for(INode n : fStartActivities) {
-
- // The correlation validator sets these.
+
+ for(INode n : this.fStartActivities) {
+
+ // The correlation validator sets these.
List<INode> correlationSets = Collections.emptyList();
if (containsValueKey(n,"correlation.sets")) {
correlationSets = getValue(n,"correlation.sets",null);
}
-
+
// First time through the loop ?
if (commonSets == null) {
commonSets = new ArrayList<INode>( correlationSets );
continue ;
- }
-
+ }
+
if (commonSets.size() > 0) {
-
- List<INode> intersection = new ArrayList<INode>();
+
+ List<INode> intersection = new ArrayList<INode>();
for(INode i1 : commonSets ) {
- for(INode i2 : correlationSets) {
+ for(INode i2 : correlationSets) {
if (i1.equals(i2)) {
intersection.add(i2);
- }
+ }
}
}
-
+
commonSets.clear();
commonSets.addAll(intersection);
}
}
-
-
+
+
/** all start activities do *not* specify a correlation */
if (commonSets == null) {
return ;
}
-
+
IProblem problem;
-
- for(INode s : fStartActivities) {
+
+ for(INode s : this.fStartActivities) {
INode correlationsNode = mSelector.selectNode(s, ND_CORRELATIONS);
-
+
if (commonSets.size () == 0 ) {
problem = createError(s);
problem.fill("BPELC_CORRELATION__COMMON",
s.nodeName(),
- fStartActivities.size()
-
+ this.fStartActivities.size()
+
);
-
+
} else {
-
+
for ( INode correlationSet : commonSets ) {
-
+
String name = correlationSet.getAttribute(AT_NAME);
-
+
if (name == null) {
continue;
}
-
- INode correlationNode = mSelector.selectNode(correlationsNode,
+
+ INode correlationNode = mSelector.selectNode(correlationsNode,
ND_CORRELATION,
new NodeAttributeValueFilter(AT_SET,name) );
-
+
if ( isUndefined( correlationNode ) ) {
continue;
}
-
+
if (JOIN.equals(correlationNode.getAttribute(AT_INITIATE)) == false) {
problem = createError( correlationNode );
problem.fill("BPELC_CORRELATION__JOIN",
correlationNode.nodeName(),
AT_INITIATE,
JOIN );
- }
-
+ }
+
}
- }
-
+ }
+
}
}
-
-
-
+
+
+
/**
* Check the references types against the imports that we have.
*
@@ -369,13 +362,13 @@
// implemented missing code
public void rule_CheckReferencedTypes () {
IProblem problem;
- Process process = (Process) mModelQuery.lookupProcess(mNode);
-
- for(INode node : fTypeToCheckList) {
-
- List<Import> conflicts = mModelQuery.findConflictingXSD(process, node);
+ Process process = this.mModelQuery.lookupProcess(this.mNode);
+
+ for(INode node : this.fTypeToCheckList) {
+
+ List<Import> conflicts = this.mModelQuery.findConflictingXSD(process, node);
if (conflicts!=null) {
-
+
String conflicting = null;
for (int i=1; i<conflicts.size(); ++i) {
if (conflicting == null)
@@ -387,20 +380,20 @@
problem.fill("BPELC_XSD__CONFLICTING_DEFINITION",
node.getAttribute(AT_NAME),
conflicts.get(0).getLocation(),
- conflicting
-
+ conflicting
+
);
-
+
}
- }
+ }
}
-
-
+
+
/** End of public rule methods.
- *
+ *
* Other methods are support methods for this class to perform its
* validation function.
- *
+ *
*/
}
diff --git a/pom.xml b/pom.xml
index c0c0f63..0a31133 100644
--- a/pom.xml
+++ b/pom.xml
@@ -3,18 +3,12 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.eclipse</groupId>
<artifactId>bpel</artifactId>
- <name>bpel.all</name>
+ <name>bpel.test</name>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<modules>
- <!-- must build parent BEFORE building the rest of this project
- <module>parent</module> -->
-
- <module>plugins</module>
- <!-- <module>tests</module> -->
- <!-- <module>examples></module> -->
- <module>features</module>
- <module>site</module>
+ <module>org.eclipse.bpel.common.wsdl.tests</module>
+ <module>org.eclipse.bpel.ui.tests</module>
</modules>
</project>
diff --git a/tests/org.eclipse.bpel.common.wsdl.tests/.classpath b/tests/org.eclipse.bpel.common.wsdl.tests/.classpath
new file mode 100644
index 0000000..e3476c7
--- /dev/null
+++ b/tests/org.eclipse.bpel.common.wsdl.tests/.classpath
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="src" path="resources"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/tests/org.eclipse.bpel.common.wsdl.tests/.project b/tests/org.eclipse.bpel.common.wsdl.tests/.project
new file mode 100644
index 0000000..4b0004e
--- /dev/null
+++ b/tests/org.eclipse.bpel.common.wsdl.tests/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.bpel.common.wsdl.tests</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/tests/org.eclipse.bpel.common.wsdl.tests/META-INF/MANIFEST.MF b/tests/org.eclipse.bpel.common.wsdl.tests/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..1b05ab0
--- /dev/null
+++ b/tests/org.eclipse.bpel.common.wsdl.tests/META-INF/MANIFEST.MF
@@ -0,0 +1,14 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Tests - SOA Commons for WSDL and XML Schemas
+Bundle-SymbolicName: org.eclipse.bpel.common.wsdl.tests;singleton:=true
+Bundle-Version: 1.0.0.qualifier
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Bundle-Vendor: Eclipse.org
+Bundle-ActivationPolicy: lazy
+Require-Bundle: org.junit4,
+ org.eclipse.bpel.common.wsdl,
+ org.eclipse.emf.ecore.xmi,
+ org.eclipse.wst.wsdl,
+ javax.wsdl;bundle-version="1.5.1",
+ org.eclipse.xsd
diff --git a/tests/org.eclipse.bpel.common.wsdl.tests/build.properties b/tests/org.eclipse.bpel.common.wsdl.tests/build.properties
new file mode 100644
index 0000000..a2e16df
--- /dev/null
+++ b/tests/org.eclipse.bpel.common.wsdl.tests/build.properties
@@ -0,0 +1,5 @@
+source.. = src/,\
+ resources/
+output.. = bin/
+bin.includes = META-INF/,\
+ .
diff --git a/tests/org.eclipse.bpel.common.wsdl.tests/resources/wsdls/test1/readme.txt b/tests/org.eclipse.bpel.common.wsdl.tests/resources/wsdls/test1/readme.txt
new file mode 100644
index 0000000..f07b69b
--- /dev/null
+++ b/tests/org.eclipse.bpel.common.wsdl.tests/resources/wsdls/test1/readme.txt
@@ -0,0 +1 @@
+Simple WSDL 1.1.
\ No newline at end of file
diff --git a/tests/org.eclipse.bpel.common.wsdl.tests/resources/wsdls/test1/tuxDroid.wsdl b/tests/org.eclipse.bpel.common.wsdl.tests/resources/wsdls/test1/tuxDroid.wsdl
new file mode 100644
index 0000000..339ab46
--- /dev/null
+++ b/tests/org.eclipse.bpel.common.wsdl.tests/resources/wsdls/test1/tuxDroid.wsdl
@@ -0,0 +1,360 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<wsdl:definitions name="TuxDroid" targetNamespace="http://tuxdroid.ebmwebsourcing.com/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://tuxdroid.ebmwebsourcing.com/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
+ <wsdl:types>
+<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://tuxdroid.ebmwebsourcing.com/" attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="http://tuxdroid.ebmwebsourcing.com/">
+<xsd:element name="speak" type="tns:speak"/>
+<xsd:complexType name="speak">
+<xsd:sequence>
+<xsd:element minOccurs="0" name="arg0" type="xsd:string"/>
+</xsd:sequence>
+</xsd:complexType>
+<xsd:element name="speakResponse" type="tns:speakResponse"/>
+<xsd:complexType name="speakResponse">
+<xsd:sequence/>
+</xsd:complexType>
+<xsd:element name="flippersUp" type="tns:flippersUp"/>
+<xsd:complexType name="flippersUp">
+<xsd:sequence/>
+</xsd:complexType>
+<xsd:element name="flippersUpResponse" type="tns:flippersUpResponse"/>
+<xsd:complexType name="flippersUpResponse">
+<xsd:sequence/>
+</xsd:complexType>
+<xsd:element name="openMouth" type="tns:openMouth"/>
+<xsd:complexType name="openMouth">
+<xsd:sequence/>
+</xsd:complexType>
+<xsd:element name="openMouthResponse" type="tns:openMouthResponse"/>
+<xsd:complexType name="openMouthResponse">
+<xsd:sequence/>
+</xsd:complexType>
+<xsd:element name="start" type="tns:start"/>
+<xsd:complexType name="start">
+<xsd:sequence/>
+</xsd:complexType>
+<xsd:element name="startResponse" type="tns:startResponse"/>
+<xsd:complexType name="startResponse">
+<xsd:sequence/>
+</xsd:complexType>
+<xsd:element name="flippersDown" type="tns:flippersDown"/>
+<xsd:complexType name="flippersDown">
+<xsd:sequence/>
+</xsd:complexType>
+<xsd:element name="flippersDownResponse" type="tns:flippersDownResponse"/>
+<xsd:complexType name="flippersDownResponse">
+<xsd:sequence/>
+</xsd:complexType>
+<xsd:element name="closeMouth" type="tns:closeMouth"/>
+<xsd:complexType name="closeMouth">
+<xsd:sequence/>
+</xsd:complexType>
+<xsd:element name="closeMouthResponse" type="tns:closeMouthResponse"/>
+<xsd:complexType name="closeMouthResponse">
+<xsd:sequence/>
+</xsd:complexType>
+<xsd:element name="closeEyes" type="tns:closeEyes"/>
+<xsd:complexType name="closeEyes">
+<xsd:sequence/>
+</xsd:complexType>
+<xsd:element name="closeEyesResponse" type="tns:closeEyesResponse"/>
+<xsd:complexType name="closeEyesResponse">
+<xsd:sequence/>
+</xsd:complexType>
+<xsd:element name="openEyes" type="tns:openEyes"/>
+<xsd:complexType name="openEyes">
+<xsd:sequence/>
+</xsd:complexType>
+<xsd:element name="openEyesResponse" type="tns:openEyesResponse"/>
+<xsd:complexType name="openEyesResponse">
+<xsd:sequence/>
+</xsd:complexType>
+<xsd:element name="goRight" type="tns:goRight"/>
+<xsd:complexType name="goRight">
+<xsd:sequence/>
+</xsd:complexType>
+<xsd:element name="goRightResponse" type="tns:goRightResponse"/>
+<xsd:complexType name="goRightResponse">
+<xsd:sequence/>
+</xsd:complexType>
+<xsd:element name="goLeft" type="tns:goLeft"/>
+<xsd:complexType name="goLeft">
+<xsd:sequence/>
+</xsd:complexType>
+<xsd:element name="goLeftResponse" type="tns:goLeftResponse"/>
+<xsd:complexType name="goLeftResponse">
+<xsd:sequence/>
+</xsd:complexType>
+<xsd:element name="stop" type="tns:stop"/>
+<xsd:complexType name="stop">
+<xsd:sequence/>
+</xsd:complexType>
+<xsd:element name="stopResponse" type="tns:stopResponse"/>
+<xsd:complexType name="stopResponse">
+<xsd:sequence/>
+</xsd:complexType>
+</xsd:schema>
+ </wsdl:types>
+ <wsdl:message name="stopResponse">
+ <wsdl:part name="parameters" element="tns:stopResponse">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="speakResponse">
+ <wsdl:part name="parameters" element="tns:speakResponse">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="stop">
+ <wsdl:part name="parameters" element="tns:stop">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="closeEyesResponse">
+ <wsdl:part name="parameters" element="tns:closeEyesResponse">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="flippersUpResponse">
+ <wsdl:part name="parameters" element="tns:flippersUpResponse">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="speak">
+ <wsdl:part name="parameters" element="tns:speak">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="openMouth">
+ <wsdl:part name="parameters" element="tns:openMouth">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="startResponse">
+ <wsdl:part name="parameters" element="tns:startResponse">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="openMouthResponse">
+ <wsdl:part name="parameters" element="tns:openMouthResponse">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="closeMouthResponse">
+ <wsdl:part name="parameters" element="tns:closeMouthResponse">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="goRight">
+ <wsdl:part name="parameters" element="tns:goRight">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="goLeft">
+ <wsdl:part name="parameters" element="tns:goLeft">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="goRightResponse">
+ <wsdl:part name="parameters" element="tns:goRightResponse">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="closeEyes">
+ <wsdl:part name="parameters" element="tns:closeEyes">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="start">
+ <wsdl:part name="parameters" element="tns:start">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="openEyesResponse">
+ <wsdl:part name="parameters" element="tns:openEyesResponse">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="flippersUp">
+ <wsdl:part name="parameters" element="tns:flippersUp">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="closeMouth">
+ <wsdl:part name="parameters" element="tns:closeMouth">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="flippersDownResponse">
+ <wsdl:part name="parameters" element="tns:flippersDownResponse">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="openEyes">
+ <wsdl:part name="parameters" element="tns:openEyes">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="goLeftResponse">
+ <wsdl:part name="parameters" element="tns:goLeftResponse">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="flippersDown">
+ <wsdl:part name="parameters" element="tns:flippersDown">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:portType name="TuxDroidPortType">
+ <wsdl:operation name="speak">
+ <wsdl:input name="speak" message="tns:speak">
+ </wsdl:input>
+ <wsdl:output name="speakResponse" message="tns:speakResponse">
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="flippersUp">
+ <wsdl:input name="flippersUp" message="tns:flippersUp">
+ </wsdl:input>
+ <wsdl:output name="flippersUpResponse" message="tns:flippersUpResponse">
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="openMouth">
+ <wsdl:input name="openMouth" message="tns:openMouth">
+ </wsdl:input>
+ <wsdl:output name="openMouthResponse" message="tns:openMouthResponse">
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="start">
+ <wsdl:input name="start" message="tns:start">
+ </wsdl:input>
+ <wsdl:output name="startResponse" message="tns:startResponse">
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="flippersDown">
+ <wsdl:input name="flippersDown" message="tns:flippersDown">
+ </wsdl:input>
+ <wsdl:output name="flippersDownResponse" message="tns:flippersDownResponse">
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="closeMouth">
+ <wsdl:input name="closeMouth" message="tns:closeMouth">
+ </wsdl:input>
+ <wsdl:output name="closeMouthResponse" message="tns:closeMouthResponse">
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="closeEyes">
+ <wsdl:input name="closeEyes" message="tns:closeEyes">
+ </wsdl:input>
+ <wsdl:output name="closeEyesResponse" message="tns:closeEyesResponse">
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="openEyes">
+ <wsdl:input name="openEyes" message="tns:openEyes">
+ </wsdl:input>
+ <wsdl:output name="openEyesResponse" message="tns:openEyesResponse">
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="goRight">
+ <wsdl:input name="goRight" message="tns:goRight">
+ </wsdl:input>
+ <wsdl:output name="goRightResponse" message="tns:goRightResponse">
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="goLeft">
+ <wsdl:input name="goLeft" message="tns:goLeft">
+ </wsdl:input>
+ <wsdl:output name="goLeftResponse" message="tns:goLeftResponse">
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="stop">
+ <wsdl:input name="stop" message="tns:stop">
+ </wsdl:input>
+ <wsdl:output name="stopResponse" message="tns:stopResponse">
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:portType>
+ <wsdl:binding name="TuxDroidSoapBinding" type="tns:TuxDroidPortType">
+ <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
+ <wsdl:operation name="speak">
+ <soap:operation soapAction="" style="document"/>
+ <wsdl:input name="speak">
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output name="speakResponse">
+ <soap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="flippersUp">
+ <soap:operation soapAction="" style="document"/>
+ <wsdl:input name="flippersUp">
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output name="flippersUpResponse">
+ <soap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="openMouth">
+ <soap:operation soapAction="" style="document"/>
+ <wsdl:input name="openMouth">
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output name="openMouthResponse">
+ <soap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="start">
+ <soap:operation soapAction="" style="document"/>
+ <wsdl:input name="start">
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output name="startResponse">
+ <soap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="closeMouth">
+ <soap:operation soapAction="" style="document"/>
+ <wsdl:input name="closeMouth">
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output name="closeMouthResponse">
+ <soap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="flippersDown">
+ <soap:operation soapAction="" style="document"/>
+ <wsdl:input name="flippersDown">
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output name="flippersDownResponse">
+ <soap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="closeEyes">
+ <soap:operation soapAction="" style="document"/>
+ <wsdl:input name="closeEyes">
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output name="closeEyesResponse">
+ <soap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="openEyes">
+ <soap:operation soapAction="" style="document"/>
+ <wsdl:input name="openEyes">
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output name="openEyesResponse">
+ <soap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="goRight">
+ <soap:operation soapAction="" style="document"/>
+ <wsdl:input name="goRight">
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output name="goRightResponse">
+ <soap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="goLeft">
+ <soap:operation soapAction="" style="document"/>
+ <wsdl:input name="goLeft">
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output name="goLeftResponse">
+ <soap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="stop">
+ <soap:operation soapAction="" style="document"/>
+ <wsdl:input name="stop">
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output name="stopResponse">
+ <soap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:binding>
+ <wsdl:service name="TuxDroid">
+ <wsdl:port name="TuxDroidPort" binding="tns:TuxDroidSoapBinding">
+ <soap:address location="http://localhost:9090/TuxDroidPort"/>
+ </wsdl:port>
+ </wsdl:service>
+</wsdl:definitions>
diff --git a/tests/org.eclipse.bpel.common.wsdl.tests/resources/wsdls/test2/readme.txt b/tests/org.eclipse.bpel.common.wsdl.tests/resources/wsdls/test2/readme.txt
new file mode 100644
index 0000000..13640fa
--- /dev/null
+++ b/tests/org.eclipse.bpel.common.wsdl.tests/resources/wsdls/test2/readme.txt
@@ -0,0 +1 @@
+Simple WSDL 2.0.
\ No newline at end of file
diff --git a/tests/org.eclipse.bpel.common.wsdl.tests/resources/wsdls/test2/testwsdl20.wsdl b/tests/org.eclipse.bpel.common.wsdl.tests/resources/wsdls/test2/testwsdl20.wsdl
new file mode 100644
index 0000000..e37fba4
--- /dev/null
+++ b/tests/org.eclipse.bpel.common.wsdl.tests/resources/wsdls/test2/testwsdl20.wsdl
@@ -0,0 +1,80 @@
+<wsdl2:description xmlns:wsdl2="http://www.w3.org/ns/wsdl"
+ xmlns:tns="http://services.mashup.wso2.org/testService" xmlns:wsoap="http://www.w3.org/ns/wsdl/soap"
+ xmlns:axis2="http://services.mashup.wso2.org/testService" xmlns:ws="http://services.mashup.wso2.org/testService?xsd"
+ xmlns:wsdlx="http://www.w3.org/ns/wsdl-extensions" xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ xmlns:whttp="http://www.w3.org/ns/wsdl/http" xmlns="http://www.w3.org/ns/wsdl"
+ targetNamespace="http://services.mashup.wso2.org/testService">
+ <wsdl2:types>
+ <xs:schema attributeFormDefault="unqualified"
+ elementFormDefault="unqualified" targetNamespace="http://services.mashup.wso2.org/testService?xsd">
+ <xs:complexType name="echoJSstringType">
+ <xs:sequence>
+ <xs:element name="param" type="xs:string" />
+ </xs:sequence>
+ </xs:complexType>
+ <xs:element name="echoJSstring" type="ws:echoJSstringType" />
+ <xs:complexType name="echoJSstringResponseType">
+ <xs:sequence>
+ <xs:element name="return" type="xs:string" />
+ </xs:sequence>
+ </xs:complexType>
+ <xs:element name="echoJSstringResponse" type="ws:echoJSstringResponseType" />
+ </xs:schema>
+ </wsdl2:types>
+ <wsdl2:interface name="ServiceInterface">
+ <wsdl2:operation name="echoJSstring"
+ style="http://www.w3.org/ns/wsdl/style/rpc" pattern="http://www.w3.org/ns/wsdl/in-out"
+ wsdlx:safe="true">
+ <wsdl2:documentation>Echo JavaScript string</wsdl2:documentation>
+ <wsdl2:input xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl"
+ element="ws:echoJSstring" wsaw:Action="urn:echoJSstring" />
+ <wsdl2:output xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl"
+ element="ws:echoJSstringResponse" wsaw:Action="urn:echoJSstringResponse" />
+ </wsdl2:operation>
+ </wsdl2:interface>
+ <wsdl2:binding name="testServiceSOAP11Binding" interface="tns:ServiceInterface"
+ type="http://www.w3.org/ns/wsdl/soap" wsoap:version="1.1">
+ <wsdl2:operation ref="tns:echoJSstring" wsoap:action="urn:echoJSstring" />
+ </wsdl2:binding>
+ <wsdl2:binding name="testServiceSOAP12Binding" interface="tns:ServiceInterface"
+ type="http://www.w3.org/ns/wsdl/soap" wsoap:version="1.2">
+ <wsdl2:operation ref="tns:echoJSstring" wsoap:action="urn:echoJSstring" />
+ </wsdl2:binding>
+ <wsdl2:binding name="testServiceHttpBinding" interface="tns:ServiceInterface"
+ type="http://www.w3.org/ns/wsdl/http">
+ <wsdl2:operation ref="tns:echoJSstring"
+ whttp:location="testService/echoJSstring" />
+ </wsdl2:binding>
+ <wsdl2:service name="testService" interface="tns:ServiceInterface">
+ <wsdl2:endpoint name="SecureSOAP11Endpoint" binding="tns:testServiceSOAP11Binding"
+ address="https://192.168.1.50:7443/services/testService">
+ <wsdl2:documentation>This endpoint exposes a SOAP 11 binding over
+ a HTTPS</wsdl2:documentation>
+ </wsdl2:endpoint>
+ <wsdl2:endpoint name="SecureSOAP12Endpoint" binding="tns:testServiceSOAP12Binding"
+ address="https://192.168.1.50:7443/services/testService">
+ <wsdl2:documentation>This endpoint exposes a SOAP 12 binding over
+ a HTTPS</wsdl2:documentation>
+ </wsdl2:endpoint>
+ <wsdl2:endpoint name="SecureHTTPEndpoint" binding="tns:testServiceHttpBinding"
+ address="https://192.168.1.50:7443/services/testService">
+ <wsdl2:documentation>Thi
+ s endpoint exposes a HTTP binding over a HTTPS</wsdl2:documentation>
+ </wsdl2:endpoint>
+ <wsdl2:endpoint name="SOAP11Endpoint" binding="tns:testServiceSOAP11Binding"
+ address="http://192.168.1.50:7762/services/testService">
+ <wsdl2:documentation>This endpoint exposes a SOAP 11 binding over
+ a HTTP</wsdl2:documentation>
+ </wsdl2:endpoint>
+ <wsdl2:endpoint name="SOAP12Endpoint" binding="tns:testServiceSOAP12Binding"
+ address="http://192.168.1.50:7762/services/testService">
+ <wsdl2:documentation>This endpoint exposes a SOAP 12 binding over
+ a HTTP</wsdl2:documentation>
+ </wsdl2:endpoint>
+ <wsdl2:endpoint name="HTTPEndpoint" binding="tns:testServiceHttpBinding"
+ address="http://192.168.1.50:7762/services/testService">
+ <wsdl2:documentation>This endpoint exposes a HTTP binding over a
+ HTTP</wsdl2:documentation>
+ </wsdl2:endpoint>
+ </wsdl2:service>
+</wsdl2:description>
diff --git a/tests/org.eclipse.bpel.common.wsdl.tests/resources/wsdls/test3/To.wsdl b/tests/org.eclipse.bpel.common.wsdl.tests/resources/wsdls/test3/To.wsdl
new file mode 100644
index 0000000..f214048
--- /dev/null
+++ b/tests/org.eclipse.bpel.common.wsdl.tests/resources/wsdls/test3/To.wsdl
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<!-- Generated by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is JAX-WS RI 2.1.6 in JDK 6. -->
+<definitions targetNamespace="http://ser" name="To" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://ser" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
+ <types>
+ <xsd:schema>
+ <xsd:import namespace="http://ser" schemaLocation="To_schema1.xsd"/>
+ </xsd:schema>
+ </types>
+ <message name="helloWorld">
+ <part name="parameters" element="tns:helloWorld"/>
+ </message>
+ <message name="helloWorldResponse">
+ <part name="parameters" element="tns:helloWorldResponse"/>
+ </message>
+ <message name="listenToTheWorld">
+ <part name="parameters" element="tns:listenToTheWorld"/>
+ </message>
+ <portType name="To">
+ <operation name="helloWorld">
+ <input message="tns:helloWorld"/>
+ <output message="tns:helloWorldResponse"/>
+ </operation>
+ <operation name="listenToTheWorld">
+ <input message="tns:listenToTheWorld"/>
+ </operation>
+ </portType>
+ <binding name="ToPortBinding" type="tns:To">
+ <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
+ <operation name="helloWorld">
+ <soap:operation soapAction=""/>
+ <input>
+ <soap:body use="literal"/>
+ </input>
+ <output>
+ <soap:body use="literal"/>
+ </output>
+ </operation>
+ <operation name="listenToTheWorld">
+ <soap:operation soapAction=""/>
+ <input>
+ <soap:body use="literal"/>
+ </input>
+ </operation>
+ </binding>
+ <service name="To">
+ <port name="ToPort" binding="tns:ToPortBinding">
+ <soap:address location="REPLACE_WITH_ACTUAL_URL"/>
+ </port>
+ </service>
+</definitions>
+
diff --git a/tests/org.eclipse.bpel.common.wsdl.tests/resources/wsdls/test3/To_schema1.xsd b/tests/org.eclipse.bpel.common.wsdl.tests/resources/wsdls/test3/To_schema1.xsd
new file mode 100644
index 0000000..123eb4e
--- /dev/null
+++ b/tests/org.eclipse.bpel.common.wsdl.tests/resources/wsdls/test3/To_schema1.xsd
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<xs:schema version="1.0" targetNamespace="http://ser" xmlns:tns="http://ser" xmlns:xs="http://www.w3.org/2001/XMLSchema">
+
+ <xs:element name="helloWorld" type="tns:helloWorld"/>
+
+ <xs:element name="helloWorldResponse" type="tns:helloWorldResponse"/>
+
+ <xs:element name="listenToTheWorld" type="tns:listenToTheWorld"/>
+
+ <xs:complexType name="helloWorld">
+ <xs:sequence/>
+ </xs:complexType>
+
+ <xs:complexType name="helloWorldResponse">
+ <xs:sequence>
+ <xs:element name="returnMessage" type="xs:string" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="listenToTheWorld">
+ <xs:sequence>
+ <xs:element name="message" type="xs:string" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+</xs:schema>
+
diff --git a/tests/org.eclipse.bpel.common.wsdl.tests/resources/wsdls/test3/readme.txt b/tests/org.eclipse.bpel.common.wsdl.tests/resources/wsdls/test3/readme.txt
new file mode 100644
index 0000000..4eff126
--- /dev/null
+++ b/tests/org.eclipse.bpel.common.wsdl.tests/resources/wsdls/test3/readme.txt
@@ -0,0 +1 @@
+Simple WSDL 1.1 with a XML schema import (1 sub-level).
\ No newline at end of file
diff --git a/tests/org.eclipse.bpel.common.wsdl.tests/resources/wsdls/test4/To.wsdl b/tests/org.eclipse.bpel.common.wsdl.tests/resources/wsdls/test4/To.wsdl
new file mode 100644
index 0000000..c5fee37
--- /dev/null
+++ b/tests/org.eclipse.bpel.common.wsdl.tests/resources/wsdls/test4/To.wsdl
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<!-- Generated by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is JAX-WS RI 2.1.6 in JDK 6. -->
+<definitions targetNamespace="http://ser" name="To" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://ser" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
+ <types>
+ <xsd:schema>
+ <xsd:import namespace="http://ser" schemaLocation="level1/To_schema1.xsd"/>
+ </xsd:schema>
+ </types>
+ <message name="helloWorld">
+ <part name="parameters" element="tns:helloWorld"/>
+ </message>
+ <message name="helloWorldResponse">
+ <part name="parameters" element="tns:helloWorldResponse"/>
+ </message>
+ <message name="listenToTheWorld">
+ <part name="parameters" element="tns:listenToTheWorld"/>
+ </message>
+ <portType name="To">
+ <operation name="helloWorld">
+ <input message="tns:helloWorld"/>
+ <output message="tns:helloWorldResponse"/>
+ </operation>
+ <operation name="listenToTheWorld">
+ <input message="tns:listenToTheWorld"/>
+ </operation>
+ </portType>
+ <binding name="ToPortBinding" type="tns:To">
+ <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
+ <operation name="helloWorld">
+ <soap:operation soapAction=""/>
+ <input>
+ <soap:body use="literal"/>
+ </input>
+ <output>
+ <soap:body use="literal"/>
+ </output>
+ </operation>
+ <operation name="listenToTheWorld">
+ <soap:operation soapAction=""/>
+ <input>
+ <soap:body use="literal"/>
+ </input>
+ </operation>
+ </binding>
+ <service name="To">
+ <port name="ToPort" binding="tns:ToPortBinding">
+ <soap:address location="REPLACE_WITH_ACTUAL_URL"/>
+ </port>
+ </service>
+</definitions>
+
diff --git a/tests/org.eclipse.bpel.common.wsdl.tests/resources/wsdls/test4/level1/To_schema1.xsd b/tests/org.eclipse.bpel.common.wsdl.tests/resources/wsdls/test4/level1/To_schema1.xsd
new file mode 100644
index 0000000..123eb4e
--- /dev/null
+++ b/tests/org.eclipse.bpel.common.wsdl.tests/resources/wsdls/test4/level1/To_schema1.xsd
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<xs:schema version="1.0" targetNamespace="http://ser" xmlns:tns="http://ser" xmlns:xs="http://www.w3.org/2001/XMLSchema">
+
+ <xs:element name="helloWorld" type="tns:helloWorld"/>
+
+ <xs:element name="helloWorldResponse" type="tns:helloWorldResponse"/>
+
+ <xs:element name="listenToTheWorld" type="tns:listenToTheWorld"/>
+
+ <xs:complexType name="helloWorld">
+ <xs:sequence/>
+ </xs:complexType>
+
+ <xs:complexType name="helloWorldResponse">
+ <xs:sequence>
+ <xs:element name="returnMessage" type="xs:string" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="listenToTheWorld">
+ <xs:sequence>
+ <xs:element name="message" type="xs:string" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+</xs:schema>
+
diff --git a/tests/org.eclipse.bpel.common.wsdl.tests/resources/wsdls/test4/readme.txt b/tests/org.eclipse.bpel.common.wsdl.tests/resources/wsdls/test4/readme.txt
new file mode 100644
index 0000000..b6e11c6
--- /dev/null
+++ b/tests/org.eclipse.bpel.common.wsdl.tests/resources/wsdls/test4/readme.txt
@@ -0,0 +1 @@
+Simple WSDL 1.1 with a XML schema import.
\ No newline at end of file
diff --git a/tests/org.eclipse.bpel.common.wsdl.tests/resources/wsdls/test5/To.wsdl b/tests/org.eclipse.bpel.common.wsdl.tests/resources/wsdls/test5/To.wsdl
new file mode 100644
index 0000000..a168881
--- /dev/null
+++ b/tests/org.eclipse.bpel.common.wsdl.tests/resources/wsdls/test5/To.wsdl
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<!-- Generated by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is JAX-WS RI 2.1.6 in JDK 6. -->
+<definitions targetNamespace="http://ser" name="To" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://ser" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
+ <types>
+ <xsd:schema>
+ <xsd:import namespace="http://ser" schemaLocation="level1/level2/To_schema1.xsd"/>
+ </xsd:schema>
+ </types>
+ <message name="helloWorld">
+ <part name="parameters" element="tns:helloWorld"/>
+ </message>
+ <message name="helloWorldResponse">
+ <part name="parameters" element="tns:helloWorldResponse"/>
+ </message>
+ <message name="listenToTheWorld">
+ <part name="parameters" element="tns:listenToTheWorld"/>
+ </message>
+ <portType name="To">
+ <operation name="helloWorld">
+ <input message="tns:helloWorld"/>
+ <output message="tns:helloWorldResponse"/>
+ </operation>
+ <operation name="listenToTheWorld">
+ <input message="tns:listenToTheWorld"/>
+ </operation>
+ </portType>
+ <binding name="ToPortBinding" type="tns:To">
+ <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
+ <operation name="helloWorld">
+ <soap:operation soapAction=""/>
+ <input>
+ <soap:body use="literal"/>
+ </input>
+ <output>
+ <soap:body use="literal"/>
+ </output>
+ </operation>
+ <operation name="listenToTheWorld">
+ <soap:operation soapAction=""/>
+ <input>
+ <soap:body use="literal"/>
+ </input>
+ </operation>
+ </binding>
+ <service name="To">
+ <port name="ToPort" binding="tns:ToPortBinding">
+ <soap:address location="REPLACE_WITH_ACTUAL_URL"/>
+ </port>
+ </service>
+</definitions>
+
diff --git a/tests/org.eclipse.bpel.common.wsdl.tests/resources/wsdls/test5/level1/level2/To_schema1.xsd b/tests/org.eclipse.bpel.common.wsdl.tests/resources/wsdls/test5/level1/level2/To_schema1.xsd
new file mode 100644
index 0000000..123eb4e
--- /dev/null
+++ b/tests/org.eclipse.bpel.common.wsdl.tests/resources/wsdls/test5/level1/level2/To_schema1.xsd
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<xs:schema version="1.0" targetNamespace="http://ser" xmlns:tns="http://ser" xmlns:xs="http://www.w3.org/2001/XMLSchema">
+
+ <xs:element name="helloWorld" type="tns:helloWorld"/>
+
+ <xs:element name="helloWorldResponse" type="tns:helloWorldResponse"/>
+
+ <xs:element name="listenToTheWorld" type="tns:listenToTheWorld"/>
+
+ <xs:complexType name="helloWorld">
+ <xs:sequence/>
+ </xs:complexType>
+
+ <xs:complexType name="helloWorldResponse">
+ <xs:sequence>
+ <xs:element name="returnMessage" type="xs:string" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="listenToTheWorld">
+ <xs:sequence>
+ <xs:element name="message" type="xs:string" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+</xs:schema>
+
diff --git a/tests/org.eclipse.bpel.common.wsdl.tests/resources/wsdls/test5/readme.txt b/tests/org.eclipse.bpel.common.wsdl.tests/resources/wsdls/test5/readme.txt
new file mode 100644
index 0000000..b1e75e9
--- /dev/null
+++ b/tests/org.eclipse.bpel.common.wsdl.tests/resources/wsdls/test5/readme.txt
@@ -0,0 +1 @@
+Simple WSDL 1.1 with a XML schema import (2 sub-levels).
\ No newline at end of file
diff --git a/tests/org.eclipse.bpel.common.wsdl.tests/resources/wsdls/test6/To.wsdl b/tests/org.eclipse.bpel.common.wsdl.tests/resources/wsdls/test6/To.wsdl
new file mode 100644
index 0000000..a168881
--- /dev/null
+++ b/tests/org.eclipse.bpel.common.wsdl.tests/resources/wsdls/test6/To.wsdl
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<!-- Generated by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is JAX-WS RI 2.1.6 in JDK 6. -->
+<definitions targetNamespace="http://ser" name="To" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://ser" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
+ <types>
+ <xsd:schema>
+ <xsd:import namespace="http://ser" schemaLocation="level1/level2/To_schema1.xsd"/>
+ </xsd:schema>
+ </types>
+ <message name="helloWorld">
+ <part name="parameters" element="tns:helloWorld"/>
+ </message>
+ <message name="helloWorldResponse">
+ <part name="parameters" element="tns:helloWorldResponse"/>
+ </message>
+ <message name="listenToTheWorld">
+ <part name="parameters" element="tns:listenToTheWorld"/>
+ </message>
+ <portType name="To">
+ <operation name="helloWorld">
+ <input message="tns:helloWorld"/>
+ <output message="tns:helloWorldResponse"/>
+ </operation>
+ <operation name="listenToTheWorld">
+ <input message="tns:listenToTheWorld"/>
+ </operation>
+ </portType>
+ <binding name="ToPortBinding" type="tns:To">
+ <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
+ <operation name="helloWorld">
+ <soap:operation soapAction=""/>
+ <input>
+ <soap:body use="literal"/>
+ </input>
+ <output>
+ <soap:body use="literal"/>
+ </output>
+ </operation>
+ <operation name="listenToTheWorld">
+ <soap:operation soapAction=""/>
+ <input>
+ <soap:body use="literal"/>
+ </input>
+ </operation>
+ </binding>
+ <service name="To">
+ <port name="ToPort" binding="tns:ToPortBinding">
+ <soap:address location="REPLACE_WITH_ACTUAL_URL"/>
+ </port>
+ </service>
+</definitions>
+
diff --git a/tests/org.eclipse.bpel.common.wsdl.tests/resources/wsdls/test6/level1/To_schema2.xsd b/tests/org.eclipse.bpel.common.wsdl.tests/resources/wsdls/test6/level1/To_schema2.xsd
new file mode 100644
index 0000000..ae9b955
--- /dev/null
+++ b/tests/org.eclipse.bpel.common.wsdl.tests/resources/wsdls/test6/level1/To_schema2.xsd
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<xs:schema version="1.0" targetNamespace="http://ser/types" xmlns:tns="http://ser" xmlns:types="http://ser/types" xmlns:xs="http://www.w3.org/2001/XMLSchema">
+
+ <!-- Useless import, we just want to test dependency loops. -->
+ <xs:import namespace="http://ser" schemaLocation="level2/To_schema1.xsd" />
+
+ <xs:complexType name="helloWorld">
+ <xs:sequence/>
+ </xs:complexType>
+
+ <xs:complexType name="helloWorldResponse">
+ <xs:sequence>
+ <xs:element name="returnMessage" type="xs:string" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="listenToTheWorld">
+ <xs:sequence>
+ <xs:element name="message" type="xs:string" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+</xs:schema>
diff --git a/tests/org.eclipse.bpel.common.wsdl.tests/resources/wsdls/test6/level1/level2/To_schema1.xsd b/tests/org.eclipse.bpel.common.wsdl.tests/resources/wsdls/test6/level1/level2/To_schema1.xsd
new file mode 100644
index 0000000..2a4bf97
--- /dev/null
+++ b/tests/org.eclipse.bpel.common.wsdl.tests/resources/wsdls/test6/level1/level2/To_schema1.xsd
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<xs:schema version="1.0" targetNamespace="http://ser" xmlns:tns="http://ser" xmlns:types="http://ser/types" xmlns:xs="http://www.w3.org/2001/XMLSchema">
+
+ <xs:import namespace="http://ser/types" schemaLocation="../To_schema2.xsd" />
+
+ <xs:element name="helloWorld" type="types:helloWorld" />
+ <xs:element name="helloWorldResponse" type="types:helloWorldResponse"/>
+ <xs:element name="listenToTheWorld" type="types:listenToTheWorld"/>
+</xs:schema>
diff --git a/tests/org.eclipse.bpel.common.wsdl.tests/resources/wsdls/test6/readme.txt b/tests/org.eclipse.bpel.common.wsdl.tests/resources/wsdls/test6/readme.txt
new file mode 100644
index 0000000..7fd89dc
--- /dev/null
+++ b/tests/org.eclipse.bpel.common.wsdl.tests/resources/wsdls/test6/readme.txt
@@ -0,0 +1,2 @@
+Simple WSDL 1.1 with a XML schema import (2 sub-levels).
+The XML schema itselfs imports another XML schema (cyclic import).
\ No newline at end of file
diff --git a/tests/org.eclipse.bpel.common.wsdl.tests/resources/wsdls/test7/ToAbstract.wsdl b/tests/org.eclipse.bpel.common.wsdl.tests/resources/wsdls/test7/ToAbstract.wsdl
new file mode 100644
index 0000000..4f2359a
--- /dev/null
+++ b/tests/org.eclipse.bpel.common.wsdl.tests/resources/wsdls/test7/ToAbstract.wsdl
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<!-- Generated by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is JAX-WS RI 2.1.6 in JDK 6. -->
+<definitions targetNamespace="http://ser" name="To" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://ser" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
+ <types>
+ <xsd:schema>
+ <xsd:import namespace="http://ser" schemaLocation="To_schema1.xsd"/>
+ </xsd:schema>
+ </types>
+ <message name="helloWorld">
+ <part name="parameters" element="tns:helloWorld"/>
+ </message>
+ <message name="helloWorldResponse">
+ <part name="parameters" element="tns:helloWorldResponse"/>
+ </message>
+ <message name="listenToTheWorld">
+ <part name="parameters" element="tns:listenToTheWorld"/>
+ </message>
+ <portType name="To">
+ <operation name="helloWorld">
+ <input message="tns:helloWorld"/>
+ <output message="tns:helloWorldResponse"/>
+ </operation>
+ <operation name="listenToTheWorld">
+ <input message="tns:listenToTheWorld"/>
+ </operation>
+ </portType>
+</definitions>
+
diff --git a/tests/org.eclipse.bpel.common.wsdl.tests/resources/wsdls/test7/ToConcrete.wsdl b/tests/org.eclipse.bpel.common.wsdl.tests/resources/wsdls/test7/ToConcrete.wsdl
new file mode 100644
index 0000000..21f2507
--- /dev/null
+++ b/tests/org.eclipse.bpel.common.wsdl.tests/resources/wsdls/test7/ToConcrete.wsdl
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<!-- Generated by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is JAX-WS RI 2.1.6 in JDK 6. -->
+<definitions
+ targetNamespace="http://ser/concrete" name="To" xmlns="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:tns="http://ser/concrete" xmlns:abs="http://ser" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
+
+ <import location="ToAbstract.wsdl" namespace="http://ser" />
+
+ <binding name="ToPortBinding" type="abs:To">
+ <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
+ <operation name="helloWorld">
+ <soap:operation soapAction=""/>
+ <input>
+ <soap:body use="literal"/>
+ </input>
+ <output>
+ <soap:body use="literal"/>
+ </output>
+ </operation>
+ <operation name="listenToTheWorld">
+ <soap:operation soapAction=""/>
+ <input>
+ <soap:body use="literal"/>
+ </input>
+ </operation>
+ </binding>
+
+ <service name="To">
+ <port name="ToPort" binding="tns:ToPortBinding">
+ <soap:address location="REPLACE_WITH_ACTUAL_URL"/>
+ </port>
+ </service>
+</definitions>
diff --git a/tests/org.eclipse.bpel.common.wsdl.tests/resources/wsdls/test7/To_schema1.xsd b/tests/org.eclipse.bpel.common.wsdl.tests/resources/wsdls/test7/To_schema1.xsd
new file mode 100644
index 0000000..123eb4e
--- /dev/null
+++ b/tests/org.eclipse.bpel.common.wsdl.tests/resources/wsdls/test7/To_schema1.xsd
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<xs:schema version="1.0" targetNamespace="http://ser" xmlns:tns="http://ser" xmlns:xs="http://www.w3.org/2001/XMLSchema">
+
+ <xs:element name="helloWorld" type="tns:helloWorld"/>
+
+ <xs:element name="helloWorldResponse" type="tns:helloWorldResponse"/>
+
+ <xs:element name="listenToTheWorld" type="tns:listenToTheWorld"/>
+
+ <xs:complexType name="helloWorld">
+ <xs:sequence/>
+ </xs:complexType>
+
+ <xs:complexType name="helloWorldResponse">
+ <xs:sequence>
+ <xs:element name="returnMessage" type="xs:string" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="listenToTheWorld">
+ <xs:sequence>
+ <xs:element name="message" type="xs:string" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+</xs:schema>
+
diff --git a/tests/org.eclipse.bpel.common.wsdl.tests/resources/wsdls/test7/readme.txt b/tests/org.eclipse.bpel.common.wsdl.tests/resources/wsdls/test7/readme.txt
new file mode 100644
index 0000000..068aa95
--- /dev/null
+++ b/tests/org.eclipse.bpel.common.wsdl.tests/resources/wsdls/test7/readme.txt
@@ -0,0 +1 @@
+Simple WSDL 1.1 with a XML schema import and a WSDL import.
\ No newline at end of file
diff --git a/tests/org.eclipse.bpel.common.wsdl.tests/resources/wsdls/test8/ToAbstract.wsdl b/tests/org.eclipse.bpel.common.wsdl.tests/resources/wsdls/test8/ToAbstract.wsdl
new file mode 100644
index 0000000..1ab61fc
--- /dev/null
+++ b/tests/org.eclipse.bpel.common.wsdl.tests/resources/wsdls/test8/ToAbstract.wsdl
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<!-- Generated by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is JAX-WS RI 2.1.6 in JDK 6. -->
+<definitions
+ targetNamespace="http://ser" name="To" xmlns="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:tns="http://ser" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
+
+ <import location="ToConcrete.wsdl" namespace="http://ser/concrete" />
+
+ <types>
+ <xsd:schema>
+ <xsd:import namespace="http://ser" schemaLocation="To_schema1.xsd"/>
+ </xsd:schema>
+ </types>
+ <message name="helloWorld">
+ <part name="parameters" element="tns:helloWorld"/>
+ </message>
+ <message name="helloWorldResponse">
+ <part name="parameters" element="tns:helloWorldResponse"/>
+ </message>
+ <message name="listenToTheWorld">
+ <part name="parameters" element="tns:listenToTheWorld"/>
+ </message>
+ <portType name="To">
+ <operation name="helloWorld">
+ <input message="tns:helloWorld"/>
+ <output message="tns:helloWorldResponse"/>
+ </operation>
+ <operation name="listenToTheWorld">
+ <input message="tns:listenToTheWorld"/>
+ </operation>
+ </portType>
+</definitions>
+
diff --git a/tests/org.eclipse.bpel.common.wsdl.tests/resources/wsdls/test8/ToConcrete.wsdl b/tests/org.eclipse.bpel.common.wsdl.tests/resources/wsdls/test8/ToConcrete.wsdl
new file mode 100644
index 0000000..21f2507
--- /dev/null
+++ b/tests/org.eclipse.bpel.common.wsdl.tests/resources/wsdls/test8/ToConcrete.wsdl
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<!-- Generated by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is JAX-WS RI 2.1.6 in JDK 6. -->
+<definitions
+ targetNamespace="http://ser/concrete" name="To" xmlns="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:tns="http://ser/concrete" xmlns:abs="http://ser" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
+
+ <import location="ToAbstract.wsdl" namespace="http://ser" />
+
+ <binding name="ToPortBinding" type="abs:To">
+ <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
+ <operation name="helloWorld">
+ <soap:operation soapAction=""/>
+ <input>
+ <soap:body use="literal"/>
+ </input>
+ <output>
+ <soap:body use="literal"/>
+ </output>
+ </operation>
+ <operation name="listenToTheWorld">
+ <soap:operation soapAction=""/>
+ <input>
+ <soap:body use="literal"/>
+ </input>
+ </operation>
+ </binding>
+
+ <service name="To">
+ <port name="ToPort" binding="tns:ToPortBinding">
+ <soap:address location="REPLACE_WITH_ACTUAL_URL"/>
+ </port>
+ </service>
+</definitions>
diff --git a/tests/org.eclipse.bpel.common.wsdl.tests/resources/wsdls/test8/To_schema1.xsd b/tests/org.eclipse.bpel.common.wsdl.tests/resources/wsdls/test8/To_schema1.xsd
new file mode 100644
index 0000000..123eb4e
--- /dev/null
+++ b/tests/org.eclipse.bpel.common.wsdl.tests/resources/wsdls/test8/To_schema1.xsd
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<xs:schema version="1.0" targetNamespace="http://ser" xmlns:tns="http://ser" xmlns:xs="http://www.w3.org/2001/XMLSchema">
+
+ <xs:element name="helloWorld" type="tns:helloWorld"/>
+
+ <xs:element name="helloWorldResponse" type="tns:helloWorldResponse"/>
+
+ <xs:element name="listenToTheWorld" type="tns:listenToTheWorld"/>
+
+ <xs:complexType name="helloWorld">
+ <xs:sequence/>
+ </xs:complexType>
+
+ <xs:complexType name="helloWorldResponse">
+ <xs:sequence>
+ <xs:element name="returnMessage" type="xs:string" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="listenToTheWorld">
+ <xs:sequence>
+ <xs:element name="message" type="xs:string" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+</xs:schema>
+
diff --git a/tests/org.eclipse.bpel.common.wsdl.tests/resources/wsdls/test8/readme.txt b/tests/org.eclipse.bpel.common.wsdl.tests/resources/wsdls/test8/readme.txt
new file mode 100644
index 0000000..704092c
--- /dev/null
+++ b/tests/org.eclipse.bpel.common.wsdl.tests/resources/wsdls/test8/readme.txt
@@ -0,0 +1,2 @@
+Simple WSDL 1.1 with a XML schema import and a WSDL import.
+The two WSDL import each other (cyclic import).
\ No newline at end of file
diff --git a/tests/org.eclipse.bpel.common.wsdl.tests/src/org/eclipse/bpel/common/wsdl/importhelpers/TestWsdlImportHelper.java b/tests/org.eclipse.bpel.common.wsdl.tests/src/org/eclipse/bpel/common/wsdl/importhelpers/TestWsdlImportHelper.java
new file mode 100644
index 0000000..fe22a86
--- /dev/null
+++ b/tests/org.eclipse.bpel.common.wsdl.tests/src/org/eclipse/bpel/common/wsdl/importhelpers/TestWsdlImportHelper.java
@@ -0,0 +1,389 @@
+/******************************************************************************
+ * Copyright (c) 2011, EBM WebSourcing
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * EBM WebSourcing - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.bpel.common.wsdl.importhelpers;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URL;
+import java.util.Collection;
+import java.util.Map;
+import java.util.UUID;
+
+import junit.framework.Assert;
+
+import org.eclipse.bpel.common.wsdl.parsers.WsdlParser;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.wst.wsdl.Definition;
+import org.junit.Test;
+
+/**
+ * Tests the WSDL importer helper (import and update).
+ * @author Vincent Zurczak - EBM WebSourcing
+ */
+public class TestWsdlImportHelper {
+
+ /**
+ * Tests the import of a simple WSDL 1.1.
+ * @throws Exception
+ */
+ @Test
+ public void testWsdlImport1() throws Exception {
+
+ File tmpDir = new File( System.getProperty( "java.io.tmpdir" ), UUID.randomUUID().toString());
+ Assert.assertTrue( tmpDir.mkdir());
+ try {
+ URL url = getClass().getResource( "/wsdls/test1/tuxDroid.wsdl" );
+ Map<String,File> map = new WsdlImportHelper().importWsdlOrXsdAndDependencies( tmpDir, url.toString());
+
+ Assert.assertEquals( map.size(), 1 );
+ Assert.assertEquals( tmpDir.listFiles().length, 1 );
+ testWsdlParsing( map.values().iterator().next(), 1 );
+
+ } finally {
+ deleteFilesRecursively( tmpDir );
+ Assert.assertFalse( tmpDir.exists());
+ }
+ }
+
+
+ /**
+ * Tests the import of a simple WSDL 1.1 with name conflict.
+ * @throws Exception
+ */
+ @Test
+ public void testWsdlImport2() throws Exception {
+
+ File tmpDir = new File( System.getProperty( "java.io.tmpdir" ), UUID.randomUUID().toString());
+ Assert.assertTrue( tmpDir.mkdir());
+ try {
+ // First import: OK
+ URL url = getClass().getResource( "/wsdls/test1/tuxDroid.wsdl" );
+ Map<String,File> map = new WsdlImportHelper().importWsdlOrXsdAndDependencies( tmpDir, url.toString());
+
+ Assert.assertEquals( map.size(), 1 );
+ testWsdlParsing( map.values().iterator().next(), 1 );
+
+ // Second import: should be renamed
+ map = new WsdlImportHelper().importWsdlOrXsdAndDependencies( tmpDir, url.toString());
+
+ Assert.assertEquals( map.size(), 1 );
+ Assert.assertEquals( tmpDir.listFiles().length, 2 );
+ testWsdlParsing( map.values().iterator().next(), 1 );
+
+ } finally {
+ deleteFilesRecursively( tmpDir );
+ Assert.assertFalse( tmpDir.exists());
+ }
+ }
+
+
+ /**
+ * Tests the import of a simple WSDL 2.0.
+ * @throws Exception
+ */
+ @Test
+ public void testWsdlImport3() throws Exception {
+
+ File tmpDir = new File( System.getProperty( "java.io.tmpdir" ), UUID.randomUUID().toString());
+ Assert.assertTrue( tmpDir.mkdir());
+ try {
+ URL url = getClass().getResource( "/wsdls/test2/testwsdl20.wsdl" );
+ Map<String,File> map = new WsdlImportHelper().importWsdlOrXsdAndDependencies( tmpDir, url.toString());
+
+ Assert.assertEquals( map.size(), 1 );
+ Assert.assertEquals( tmpDir.listFiles().length, 1 );
+
+ } finally {
+ deleteFilesRecursively( tmpDir );
+ Assert.assertFalse( tmpDir.exists());
+ }
+ }
+
+
+ /**
+ * Tests the import of a WSDL 1.1 which imports a XSD (same level).
+ * @throws Exception
+ */
+ @Test
+ public void testWsdlImport4() throws Exception {
+
+ File tmpDir = new File( System.getProperty( "java.io.tmpdir" ), UUID.randomUUID().toString());
+ Assert.assertTrue( tmpDir.mkdir());
+ try {
+ URL url = getClass().getResource( "/wsdls/test3/To.wsdl" );
+ Map<String,File> map = new WsdlImportHelper().importWsdlOrXsdAndDependencies( tmpDir, url.toString());
+
+ Assert.assertEquals( map.size(), 2 );
+ Assert.assertEquals( tmpDir.listFiles().length, 2 );
+
+ File f = map.get( url.toString());
+ Assert.assertNotNull( f );
+ testWsdlParsing( f, 1 );
+
+ } finally {
+ deleteFilesRecursively( tmpDir );
+ Assert.assertFalse( tmpDir.exists());
+ }
+ }
+
+
+ /**
+ * Tests the import of a WSDL 1.1 which imports a XSD (1 sub-level).
+ * @throws Exception
+ */
+ @Test
+ public void testWsdlImport5() throws Exception {
+
+ File tmpDir = new File( System.getProperty( "java.io.tmpdir" ), UUID.randomUUID().toString());
+ Assert.assertTrue( tmpDir.mkdir());
+ try {
+ URL url = getClass().getResource( "/wsdls/test4/To.wsdl" );
+ Map<String,File> map = new WsdlImportHelper().importWsdlOrXsdAndDependencies( tmpDir, url.toString());
+
+ Assert.assertEquals( map.size(), 2 );
+ Assert.assertEquals( tmpDir.listFiles().length, 2 );
+
+ File level1Dir = new File( tmpDir, "level1" );
+ Assert.assertTrue( level1Dir.exists());
+ Assert.assertEquals( level1Dir.listFiles().length, 1 );
+
+ File f = map.get( url.toString());
+ Assert.assertNotNull( f );
+ testWsdlParsing( f, 1 );
+
+ } finally {
+ deleteFilesRecursively( tmpDir );
+ Assert.assertFalse( tmpDir.exists());
+ }
+ }
+
+
+ /**
+ * Tests the import of a WSDL 1.1 which imports a XSD (2 sub-levels).
+ * @throws Exception
+ */
+ @Test
+ public void testWsdlImport6() throws Exception {
+
+ File tmpDir = new File( System.getProperty( "java.io.tmpdir" ), UUID.randomUUID().toString());
+ Assert.assertTrue( tmpDir.mkdir());
+ try {
+ URL url = getClass().getResource( "/wsdls/test5/To.wsdl" );
+ Map<String,File> map = new WsdlImportHelper().importWsdlOrXsdAndDependencies( tmpDir, url.toString());
+
+ Assert.assertEquals( map.size(), 2 );
+ Assert.assertEquals( tmpDir.listFiles().length, 2 );
+
+ File level2Dir = new File( tmpDir, "level1/level2" );
+ Assert.assertTrue( level2Dir.exists());
+ Assert.assertEquals( level2Dir.listFiles().length, 1 );
+ Assert.assertEquals( level2Dir.getParentFile().listFiles().length, 1 );
+
+ File f = map.get( url.toString());
+ Assert.assertNotNull( f );
+ testWsdlParsing( f, 1 );
+
+ } finally {
+ deleteFilesRecursively( tmpDir );
+ Assert.assertFalse( tmpDir.exists());
+ }
+ }
+
+
+ /**
+ * Tests the import of a WSDL 1.1 which imports several XSD (2 sub-levels).
+ * <p>
+ * And to limit the number of tests, these two XSDs import each other.
+ * This way, we can test the support of loops in the imports.
+ * </p>
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testWsdlImport7() throws Exception {
+
+ File tmpDir = new File( System.getProperty( "java.io.tmpdir" ), UUID.randomUUID().toString());
+ Assert.assertTrue( tmpDir.mkdir());
+ try {
+ URL url = getClass().getResource( "/wsdls/test6/To.wsdl" );
+ Map<String,File> map = new WsdlImportHelper().importWsdlOrXsdAndDependencies( tmpDir, url.toString());
+
+ Assert.assertEquals( map.size(), 3 );
+ Assert.assertEquals( tmpDir.listFiles().length, 2 );
+
+ File level2Dir = new File( tmpDir, "level1/level2" );
+ Assert.assertTrue( level2Dir.exists());
+ Assert.assertEquals( level2Dir.listFiles().length, 1 );
+ Assert.assertEquals( level2Dir.getParentFile().listFiles().length, 2 );
+
+ File f = map.get( url.toString());
+ Assert.assertNotNull( f );
+ testWsdlParsing( f, 1 );
+
+ } finally {
+ deleteFilesRecursively( tmpDir );
+ Assert.assertFalse( tmpDir.exists());
+ }
+ }
+
+
+ /**
+ * Tests the import of a XSD with an import of another XSD (upper-level => the import will be relocated).
+ * @throws Exception
+ */
+ @Test
+ public void testWsdlImport8() throws Exception {
+
+ File tmpDir = new File( System.getProperty( "java.io.tmpdir" ), UUID.randomUUID().toString());
+ Assert.assertTrue( tmpDir.mkdir());
+ try {
+ URL url = getClass().getResource( "/wsdls/test6/level1/level2/To_schema1.xsd" );
+ Map<String,File> map = new WsdlImportHelper().importWsdlOrXsdAndDependencies( tmpDir, url.toString());
+
+ Assert.assertEquals( map.size(), 2 );
+ Assert.assertEquals( tmpDir.listFiles().length, 2 );
+
+ File relocatedDir = new File( tmpDir, WsdlImportHelper.RELOCATED_DIRECTORY );
+ Assert.assertTrue( relocatedDir.exists());
+ Assert.assertEquals( relocatedDir.listFiles().length, 1 );
+
+ } finally {
+ deleteFilesRecursively( tmpDir );
+ Assert.assertFalse( tmpDir.exists());
+ }
+ }
+
+
+ /**
+ * Tests the import of a XSD with an import of another XSD (sub-level).
+ * @throws Exception
+ */
+ @Test
+ public void testWsdlImport9() throws Exception {
+
+ File tmpDir = new File( System.getProperty( "java.io.tmpdir" ), UUID.randomUUID().toString());
+ Assert.assertTrue( tmpDir.mkdir());
+ try {
+ URL url = getClass().getResource( "/wsdls/test6/level1/To_schema2.xsd" );
+ Map<String,File> map = new WsdlImportHelper().importWsdlOrXsdAndDependencies( tmpDir, url.toString());
+
+ Assert.assertEquals( map.size(), 2 );
+ Assert.assertEquals( tmpDir.listFiles().length, 2 );
+
+ File level2Dir = new File( tmpDir, "level2" );
+ Assert.assertTrue( level2Dir.exists());
+ Assert.assertEquals( level2Dir.listFiles().length, 1 );
+
+ } finally {
+ deleteFilesRecursively( tmpDir );
+ Assert.assertFalse( tmpDir.exists());
+ }
+ }
+
+
+ /**
+ * Tests a WSDL 1.1 which imports a WSDL and a XML schema (same level).
+ * @throws Exception
+ */
+ @Test
+ public void testWsdlImport10() throws Exception {
+
+ File tmpDir = new File( System.getProperty( "java.io.tmpdir" ), UUID.randomUUID().toString());
+ Assert.assertTrue( tmpDir.mkdir());
+ try {
+ URL url = getClass().getResource( "/wsdls/test7/ToConcrete.wsdl" );
+ Map<String,File> map = new WsdlImportHelper().importWsdlOrXsdAndDependencies( tmpDir, url.toString());
+
+ Assert.assertEquals( map.size(), 3 );
+ Assert.assertEquals( tmpDir.listFiles().length, 3 );
+
+ File f = map.get( url.toString());
+ Assert.assertNotNull( f );
+ testWsdlParsing( f, 2 );
+
+ } finally {
+ deleteFilesRecursively( tmpDir );
+ Assert.assertFalse( tmpDir.exists());
+ }
+ }
+
+
+ /**
+ * Tests a WSDL 1.1 which imports a WSDL and a XML schema (same level).
+ * <p>
+ * There is a cyclic import in the WSDL.
+ * </p>
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testWsdlImport11() throws Exception {
+
+ File tmpDir = new File( System.getProperty( "java.io.tmpdir" ), UUID.randomUUID().toString());
+ Assert.assertTrue( tmpDir.mkdir());
+ try {
+ URL url = getClass().getResource( "/wsdls/test8/ToConcrete.wsdl" );
+ Map<String,File> map = new WsdlImportHelper().importWsdlOrXsdAndDependencies( tmpDir, url.toString());
+
+ Assert.assertEquals( map.size(), 3 );
+ Assert.assertEquals( tmpDir.listFiles().length, 3 );
+
+ File f = map.get( url.toString());
+ Assert.assertNotNull( f );
+ testWsdlParsing( f, 2 );
+
+ } finally {
+ deleteFilesRecursively( tmpDir );
+ Assert.assertFalse( tmpDir.exists());
+ }
+ }
+
+
+ /**
+ * Deletes files recursively.
+ * @param files the files to delete
+ * @throws IOException if a file could not be deleted
+ */
+ private static void deleteFilesRecursively( File... files ) throws IOException {
+
+ if( files == null )
+ return;
+
+ for( File file : files ) {
+ if( file.exists()) {
+ if( file.isDirectory())
+ deleteFilesRecursively( file.listFiles());
+
+ if( ! file.delete())
+ throw new IOException( file.getAbsolutePath() + " could not be deleted." );
+ }
+ }
+ }
+
+
+ /**
+ * Tests the parsing of an imported WSDL.
+ * @param wsdlUrl the WSDL URL
+ * @param expectedNumberOfDefinitions the number of definitions, including those found from import declarations
+ */
+ private static void testWsdlParsing( File wsdlFile, int expectedNumberOfDefinitions ) {
+
+ // Parse the imported WSDL
+ URI emfUri = URI.createFileURI( wsdlFile.getAbsolutePath());
+ Definition def = WsdlParser.loadWsdlDefinition( emfUri, WsdlParser.createBasicResourceSetForWsdl());
+ Assert.assertNotNull( def );
+
+ // Check the imports
+ Collection<Definition> definitions = WsdlParser.loadAllWsdlDefinitions( emfUri, WsdlParser.createBasicResourceSetForWsdl());
+ Assert.assertEquals( definitions.size(), expectedNumberOfDefinitions );
+ }
+}
diff --git a/tests/org.eclipse.bpel.common.wsdl.tests/src/org/eclipse/bpel/common/wsdl/parsers/TestWsdlParser.java b/tests/org.eclipse.bpel.common.wsdl.tests/src/org/eclipse/bpel/common/wsdl/parsers/TestWsdlParser.java
new file mode 100644
index 0000000..8063957
--- /dev/null
+++ b/tests/org.eclipse.bpel.common.wsdl.tests/src/org/eclipse/bpel/common/wsdl/parsers/TestWsdlParser.java
@@ -0,0 +1,92 @@
+/******************************************************************************
+ * Copyright (c) 2011, EBM WebSourcing
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * EBM WebSourcing - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.bpel.common.wsdl.parsers;
+
+import java.net.URL;
+import java.util.Collection;
+
+import junit.framework.Assert;
+
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.wst.wsdl.Definition;
+import org.junit.Test;
+
+/**
+ * Tests the WSDL parser.
+ * @author Vincent Zurczak - EBM WebSourcing
+ */
+public class TestWsdlParser {
+
+ /**
+ * Tests the parsing of a simple WSDL 1.1.
+ * @throws Exception
+ */
+ @Test
+ public void testWsdlParsing1() throws Exception {
+
+ URL url = getClass().getResource( "/wsdls/test1/tuxDroid.wsdl" );
+ URI emfUri = URI.createURI( url.toString());
+ Definition def = WsdlParser.loadWsdlDefinition( emfUri, WsdlParser.createBasicResourceSetForWsdl());
+ Assert.assertNotNull( def );
+
+ Collection<Definition> definitions = WsdlParser.loadAllWsdlDefinitions( emfUri, WsdlParser.createBasicResourceSetForWsdl());
+ Assert.assertEquals( definitions.size(), 1 );
+ }
+
+
+ /**
+ * Tests the parsing of a simple WSDL 2.0 (should not work).
+ * @throws Exception
+ */
+ @Test
+ public void testWsdlParsing2() throws Exception {
+
+ URL url = getClass().getResource( "/wsdls/test2/testwsdl20.wsdl" );
+ URI emfUri = URI.createURI( url.toString());
+ Definition def = WsdlParser.loadWsdlDefinition( emfUri, WsdlParser.createBasicResourceSetForWsdl());
+ Assert.assertFalse( WsdlParser.seemsValidDefinition( def ));
+ }
+
+
+ /**
+ * Tests the parsing of a WSDL 1.1 with XML schema and WSDL imports (same level).
+ * @throws Exception
+ */
+ @Test
+ public void testWsdlParsing3() throws Exception {
+
+ URL url = getClass().getResource( "/wsdls/test7/ToConcrete.wsdl" );
+ URI emfUri = URI.createURI( url.toString());
+ Definition def = WsdlParser.loadWsdlDefinition( emfUri, WsdlParser.createBasicResourceSetForWsdl());
+ Assert.assertNotNull( def );
+
+ Collection<Definition> definitions = WsdlParser.loadAllWsdlDefinitions( emfUri, WsdlParser.createBasicResourceSetForWsdl());
+ Assert.assertEquals( definitions.size(), 2 );
+ }
+
+
+ /**
+ * Tests the parsing of a WSDL 1.1 with XML schema and WSDL imports (cyclic import).
+ * @throws Exception
+ */
+ @Test
+ public void testWsdlParsing4() throws Exception {
+
+ URL url = getClass().getResource( "/wsdls/test8/ToConcrete.wsdl" );
+ URI emfUri = URI.createURI( url.toString());
+ Definition def = WsdlParser.loadWsdlDefinition( emfUri, WsdlParser.createBasicResourceSetForWsdl());
+ Assert.assertNotNull( def );
+
+ Collection<Definition> definitions = WsdlParser.loadAllWsdlDefinitions( emfUri, WsdlParser.createBasicResourceSetForWsdl());
+ Assert.assertEquals( definitions.size(), 2 );
+ }
+}
diff --git a/tests/org.eclipse.bpel.ui.tests/.classpath b/tests/org.eclipse.bpel.ui.tests/.classpath
new file mode 100644
index 0000000..e3476c7
--- /dev/null
+++ b/tests/org.eclipse.bpel.ui.tests/.classpath
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="src" path="resources"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/tests/org.eclipse.bpel.ui.tests/.project b/tests/org.eclipse.bpel.ui.tests/.project
new file mode 100644
index 0000000..83ee561
--- /dev/null
+++ b/tests/org.eclipse.bpel.ui.tests/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.bpel.ui.tests</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/tests/org.eclipse.bpel.ui.tests/META-INF/MANIFEST.MF b/tests/org.eclipse.bpel.ui.tests/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..6664470
--- /dev/null
+++ b/tests/org.eclipse.bpel.ui.tests/META-INF/MANIFEST.MF
@@ -0,0 +1,17 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Tests - BPEL Editor
+Bundle-SymbolicName: org.eclipse.bpel.ui.tests;singleton:=true
+Bundle-Version: 1.0.0.qualifier
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Bundle-ActivationPolicy: lazy
+Bundle-Vendor: Eclipse.org
+Require-Bundle: org.eclipse.swtbot.eclipse.core,
+ org.eclipse.swtbot.eclipse.finder,
+ org.eclipse.swtbot.eclipse.ui,
+ org.eclipse.swtbot.swt.finder,
+ org.junit4,
+ org.eclipse.ui,
+ org.eclipse.core.resources,
+ org.eclipse.ui.ide,
+ org.eclipse.core.runtime
diff --git a/tests/org.eclipse.bpel.ui.tests/build.properties b/tests/org.eclipse.bpel.ui.tests/build.properties
new file mode 100644
index 0000000..a2e16df
--- /dev/null
+++ b/tests/org.eclipse.bpel.ui.tests/build.properties
@@ -0,0 +1,5 @@
+source.. = src/,\
+ resources/
+output.. = bin/
+bin.includes = META-INF/,\
+ .
diff --git a/tests/org.eclipse.bpel.ui.tests/resources/wsdls/test1/readme.txt b/tests/org.eclipse.bpel.ui.tests/resources/wsdls/test1/readme.txt
new file mode 100644
index 0000000..f07b69b
--- /dev/null
+++ b/tests/org.eclipse.bpel.ui.tests/resources/wsdls/test1/readme.txt
@@ -0,0 +1 @@
+Simple WSDL 1.1.
\ No newline at end of file
diff --git a/tests/org.eclipse.bpel.ui.tests/resources/wsdls/test1/tuxDroid.wsdl b/tests/org.eclipse.bpel.ui.tests/resources/wsdls/test1/tuxDroid.wsdl
new file mode 100644
index 0000000..339ab46
--- /dev/null
+++ b/tests/org.eclipse.bpel.ui.tests/resources/wsdls/test1/tuxDroid.wsdl
@@ -0,0 +1,360 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<wsdl:definitions name="TuxDroid" targetNamespace="http://tuxdroid.ebmwebsourcing.com/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://tuxdroid.ebmwebsourcing.com/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
+ <wsdl:types>
+<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://tuxdroid.ebmwebsourcing.com/" attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="http://tuxdroid.ebmwebsourcing.com/">
+<xsd:element name="speak" type="tns:speak"/>
+<xsd:complexType name="speak">
+<xsd:sequence>
+<xsd:element minOccurs="0" name="arg0" type="xsd:string"/>
+</xsd:sequence>
+</xsd:complexType>
+<xsd:element name="speakResponse" type="tns:speakResponse"/>
+<xsd:complexType name="speakResponse">
+<xsd:sequence/>
+</xsd:complexType>
+<xsd:element name="flippersUp" type="tns:flippersUp"/>
+<xsd:complexType name="flippersUp">
+<xsd:sequence/>
+</xsd:complexType>
+<xsd:element name="flippersUpResponse" type="tns:flippersUpResponse"/>
+<xsd:complexType name="flippersUpResponse">
+<xsd:sequence/>
+</xsd:complexType>
+<xsd:element name="openMouth" type="tns:openMouth"/>
+<xsd:complexType name="openMouth">
+<xsd:sequence/>
+</xsd:complexType>
+<xsd:element name="openMouthResponse" type="tns:openMouthResponse"/>
+<xsd:complexType name="openMouthResponse">
+<xsd:sequence/>
+</xsd:complexType>
+<xsd:element name="start" type="tns:start"/>
+<xsd:complexType name="start">
+<xsd:sequence/>
+</xsd:complexType>
+<xsd:element name="startResponse" type="tns:startResponse"/>
+<xsd:complexType name="startResponse">
+<xsd:sequence/>
+</xsd:complexType>
+<xsd:element name="flippersDown" type="tns:flippersDown"/>
+<xsd:complexType name="flippersDown">
+<xsd:sequence/>
+</xsd:complexType>
+<xsd:element name="flippersDownResponse" type="tns:flippersDownResponse"/>
+<xsd:complexType name="flippersDownResponse">
+<xsd:sequence/>
+</xsd:complexType>
+<xsd:element name="closeMouth" type="tns:closeMouth"/>
+<xsd:complexType name="closeMouth">
+<xsd:sequence/>
+</xsd:complexType>
+<xsd:element name="closeMouthResponse" type="tns:closeMouthResponse"/>
+<xsd:complexType name="closeMouthResponse">
+<xsd:sequence/>
+</xsd:complexType>
+<xsd:element name="closeEyes" type="tns:closeEyes"/>
+<xsd:complexType name="closeEyes">
+<xsd:sequence/>
+</xsd:complexType>
+<xsd:element name="closeEyesResponse" type="tns:closeEyesResponse"/>
+<xsd:complexType name="closeEyesResponse">
+<xsd:sequence/>
+</xsd:complexType>
+<xsd:element name="openEyes" type="tns:openEyes"/>
+<xsd:complexType name="openEyes">
+<xsd:sequence/>
+</xsd:complexType>
+<xsd:element name="openEyesResponse" type="tns:openEyesResponse"/>
+<xsd:complexType name="openEyesResponse">
+<xsd:sequence/>
+</xsd:complexType>
+<xsd:element name="goRight" type="tns:goRight"/>
+<xsd:complexType name="goRight">
+<xsd:sequence/>
+</xsd:complexType>
+<xsd:element name="goRightResponse" type="tns:goRightResponse"/>
+<xsd:complexType name="goRightResponse">
+<xsd:sequence/>
+</xsd:complexType>
+<xsd:element name="goLeft" type="tns:goLeft"/>
+<xsd:complexType name="goLeft">
+<xsd:sequence/>
+</xsd:complexType>
+<xsd:element name="goLeftResponse" type="tns:goLeftResponse"/>
+<xsd:complexType name="goLeftResponse">
+<xsd:sequence/>
+</xsd:complexType>
+<xsd:element name="stop" type="tns:stop"/>
+<xsd:complexType name="stop">
+<xsd:sequence/>
+</xsd:complexType>
+<xsd:element name="stopResponse" type="tns:stopResponse"/>
+<xsd:complexType name="stopResponse">
+<xsd:sequence/>
+</xsd:complexType>
+</xsd:schema>
+ </wsdl:types>
+ <wsdl:message name="stopResponse">
+ <wsdl:part name="parameters" element="tns:stopResponse">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="speakResponse">
+ <wsdl:part name="parameters" element="tns:speakResponse">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="stop">
+ <wsdl:part name="parameters" element="tns:stop">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="closeEyesResponse">
+ <wsdl:part name="parameters" element="tns:closeEyesResponse">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="flippersUpResponse">
+ <wsdl:part name="parameters" element="tns:flippersUpResponse">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="speak">
+ <wsdl:part name="parameters" element="tns:speak">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="openMouth">
+ <wsdl:part name="parameters" element="tns:openMouth">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="startResponse">
+ <wsdl:part name="parameters" element="tns:startResponse">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="openMouthResponse">
+ <wsdl:part name="parameters" element="tns:openMouthResponse">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="closeMouthResponse">
+ <wsdl:part name="parameters" element="tns:closeMouthResponse">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="goRight">
+ <wsdl:part name="parameters" element="tns:goRight">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="goLeft">
+ <wsdl:part name="parameters" element="tns:goLeft">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="goRightResponse">
+ <wsdl:part name="parameters" element="tns:goRightResponse">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="closeEyes">
+ <wsdl:part name="parameters" element="tns:closeEyes">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="start">
+ <wsdl:part name="parameters" element="tns:start">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="openEyesResponse">
+ <wsdl:part name="parameters" element="tns:openEyesResponse">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="flippersUp">
+ <wsdl:part name="parameters" element="tns:flippersUp">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="closeMouth">
+ <wsdl:part name="parameters" element="tns:closeMouth">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="flippersDownResponse">
+ <wsdl:part name="parameters" element="tns:flippersDownResponse">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="openEyes">
+ <wsdl:part name="parameters" element="tns:openEyes">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="goLeftResponse">
+ <wsdl:part name="parameters" element="tns:goLeftResponse">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="flippersDown">
+ <wsdl:part name="parameters" element="tns:flippersDown">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:portType name="TuxDroidPortType">
+ <wsdl:operation name="speak">
+ <wsdl:input name="speak" message="tns:speak">
+ </wsdl:input>
+ <wsdl:output name="speakResponse" message="tns:speakResponse">
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="flippersUp">
+ <wsdl:input name="flippersUp" message="tns:flippersUp">
+ </wsdl:input>
+ <wsdl:output name="flippersUpResponse" message="tns:flippersUpResponse">
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="openMouth">
+ <wsdl:input name="openMouth" message="tns:openMouth">
+ </wsdl:input>
+ <wsdl:output name="openMouthResponse" message="tns:openMouthResponse">
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="start">
+ <wsdl:input name="start" message="tns:start">
+ </wsdl:input>
+ <wsdl:output name="startResponse" message="tns:startResponse">
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="flippersDown">
+ <wsdl:input name="flippersDown" message="tns:flippersDown">
+ </wsdl:input>
+ <wsdl:output name="flippersDownResponse" message="tns:flippersDownResponse">
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="closeMouth">
+ <wsdl:input name="closeMouth" message="tns:closeMouth">
+ </wsdl:input>
+ <wsdl:output name="closeMouthResponse" message="tns:closeMouthResponse">
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="closeEyes">
+ <wsdl:input name="closeEyes" message="tns:closeEyes">
+ </wsdl:input>
+ <wsdl:output name="closeEyesResponse" message="tns:closeEyesResponse">
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="openEyes">
+ <wsdl:input name="openEyes" message="tns:openEyes">
+ </wsdl:input>
+ <wsdl:output name="openEyesResponse" message="tns:openEyesResponse">
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="goRight">
+ <wsdl:input name="goRight" message="tns:goRight">
+ </wsdl:input>
+ <wsdl:output name="goRightResponse" message="tns:goRightResponse">
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="goLeft">
+ <wsdl:input name="goLeft" message="tns:goLeft">
+ </wsdl:input>
+ <wsdl:output name="goLeftResponse" message="tns:goLeftResponse">
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="stop">
+ <wsdl:input name="stop" message="tns:stop">
+ </wsdl:input>
+ <wsdl:output name="stopResponse" message="tns:stopResponse">
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:portType>
+ <wsdl:binding name="TuxDroidSoapBinding" type="tns:TuxDroidPortType">
+ <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
+ <wsdl:operation name="speak">
+ <soap:operation soapAction="" style="document"/>
+ <wsdl:input name="speak">
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output name="speakResponse">
+ <soap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="flippersUp">
+ <soap:operation soapAction="" style="document"/>
+ <wsdl:input name="flippersUp">
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output name="flippersUpResponse">
+ <soap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="openMouth">
+ <soap:operation soapAction="" style="document"/>
+ <wsdl:input name="openMouth">
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output name="openMouthResponse">
+ <soap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="start">
+ <soap:operation soapAction="" style="document"/>
+ <wsdl:input name="start">
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output name="startResponse">
+ <soap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="closeMouth">
+ <soap:operation soapAction="" style="document"/>
+ <wsdl:input name="closeMouth">
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output name="closeMouthResponse">
+ <soap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="flippersDown">
+ <soap:operation soapAction="" style="document"/>
+ <wsdl:input name="flippersDown">
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output name="flippersDownResponse">
+ <soap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="closeEyes">
+ <soap:operation soapAction="" style="document"/>
+ <wsdl:input name="closeEyes">
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output name="closeEyesResponse">
+ <soap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="openEyes">
+ <soap:operation soapAction="" style="document"/>
+ <wsdl:input name="openEyes">
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output name="openEyesResponse">
+ <soap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="goRight">
+ <soap:operation soapAction="" style="document"/>
+ <wsdl:input name="goRight">
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output name="goRightResponse">
+ <soap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="goLeft">
+ <soap:operation soapAction="" style="document"/>
+ <wsdl:input name="goLeft">
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output name="goLeftResponse">
+ <soap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="stop">
+ <soap:operation soapAction="" style="document"/>
+ <wsdl:input name="stop">
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output name="stopResponse">
+ <soap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:binding>
+ <wsdl:service name="TuxDroid">
+ <wsdl:port name="TuxDroidPort" binding="tns:TuxDroidSoapBinding">
+ <soap:address location="http://localhost:9090/TuxDroidPort"/>
+ </wsdl:port>
+ </wsdl:service>
+</wsdl:definitions>
diff --git a/tests/org.eclipse.bpel.ui.tests/resources/wsdls/test2/To.wsdl b/tests/org.eclipse.bpel.ui.tests/resources/wsdls/test2/To.wsdl
new file mode 100644
index 0000000..f214048
--- /dev/null
+++ b/tests/org.eclipse.bpel.ui.tests/resources/wsdls/test2/To.wsdl
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<!-- Generated by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is JAX-WS RI 2.1.6 in JDK 6. -->
+<definitions targetNamespace="http://ser" name="To" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://ser" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
+ <types>
+ <xsd:schema>
+ <xsd:import namespace="http://ser" schemaLocation="To_schema1.xsd"/>
+ </xsd:schema>
+ </types>
+ <message name="helloWorld">
+ <part name="parameters" element="tns:helloWorld"/>
+ </message>
+ <message name="helloWorldResponse">
+ <part name="parameters" element="tns:helloWorldResponse"/>
+ </message>
+ <message name="listenToTheWorld">
+ <part name="parameters" element="tns:listenToTheWorld"/>
+ </message>
+ <portType name="To">
+ <operation name="helloWorld">
+ <input message="tns:helloWorld"/>
+ <output message="tns:helloWorldResponse"/>
+ </operation>
+ <operation name="listenToTheWorld">
+ <input message="tns:listenToTheWorld"/>
+ </operation>
+ </portType>
+ <binding name="ToPortBinding" type="tns:To">
+ <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
+ <operation name="helloWorld">
+ <soap:operation soapAction=""/>
+ <input>
+ <soap:body use="literal"/>
+ </input>
+ <output>
+ <soap:body use="literal"/>
+ </output>
+ </operation>
+ <operation name="listenToTheWorld">
+ <soap:operation soapAction=""/>
+ <input>
+ <soap:body use="literal"/>
+ </input>
+ </operation>
+ </binding>
+ <service name="To">
+ <port name="ToPort" binding="tns:ToPortBinding">
+ <soap:address location="REPLACE_WITH_ACTUAL_URL"/>
+ </port>
+ </service>
+</definitions>
+
diff --git a/tests/org.eclipse.bpel.ui.tests/resources/wsdls/test2/To_schema1.xsd b/tests/org.eclipse.bpel.ui.tests/resources/wsdls/test2/To_schema1.xsd
new file mode 100644
index 0000000..123eb4e
--- /dev/null
+++ b/tests/org.eclipse.bpel.ui.tests/resources/wsdls/test2/To_schema1.xsd
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<xs:schema version="1.0" targetNamespace="http://ser" xmlns:tns="http://ser" xmlns:xs="http://www.w3.org/2001/XMLSchema">
+
+ <xs:element name="helloWorld" type="tns:helloWorld"/>
+
+ <xs:element name="helloWorldResponse" type="tns:helloWorldResponse"/>
+
+ <xs:element name="listenToTheWorld" type="tns:listenToTheWorld"/>
+
+ <xs:complexType name="helloWorld">
+ <xs:sequence/>
+ </xs:complexType>
+
+ <xs:complexType name="helloWorldResponse">
+ <xs:sequence>
+ <xs:element name="returnMessage" type="xs:string" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="listenToTheWorld">
+ <xs:sequence>
+ <xs:element name="message" type="xs:string" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+</xs:schema>
+
diff --git a/tests/org.eclipse.bpel.ui.tests/resources/wsdls/test2/readme.txt b/tests/org.eclipse.bpel.ui.tests/resources/wsdls/test2/readme.txt
new file mode 100644
index 0000000..4eff126
--- /dev/null
+++ b/tests/org.eclipse.bpel.ui.tests/resources/wsdls/test2/readme.txt
@@ -0,0 +1 @@
+Simple WSDL 1.1 with a XML schema import (1 sub-level).
\ No newline at end of file
diff --git a/tests/org.eclipse.bpel.ui.tests/resources/wsdls/test3/To.wsdl b/tests/org.eclipse.bpel.ui.tests/resources/wsdls/test3/To.wsdl
new file mode 100644
index 0000000..c5fee37
--- /dev/null
+++ b/tests/org.eclipse.bpel.ui.tests/resources/wsdls/test3/To.wsdl
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<!-- Generated by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is JAX-WS RI 2.1.6 in JDK 6. -->
+<definitions targetNamespace="http://ser" name="To" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://ser" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
+ <types>
+ <xsd:schema>
+ <xsd:import namespace="http://ser" schemaLocation="level1/To_schema1.xsd"/>
+ </xsd:schema>
+ </types>
+ <message name="helloWorld">
+ <part name="parameters" element="tns:helloWorld"/>
+ </message>
+ <message name="helloWorldResponse">
+ <part name="parameters" element="tns:helloWorldResponse"/>
+ </message>
+ <message name="listenToTheWorld">
+ <part name="parameters" element="tns:listenToTheWorld"/>
+ </message>
+ <portType name="To">
+ <operation name="helloWorld">
+ <input message="tns:helloWorld"/>
+ <output message="tns:helloWorldResponse"/>
+ </operation>
+ <operation name="listenToTheWorld">
+ <input message="tns:listenToTheWorld"/>
+ </operation>
+ </portType>
+ <binding name="ToPortBinding" type="tns:To">
+ <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
+ <operation name="helloWorld">
+ <soap:operation soapAction=""/>
+ <input>
+ <soap:body use="literal"/>
+ </input>
+ <output>
+ <soap:body use="literal"/>
+ </output>
+ </operation>
+ <operation name="listenToTheWorld">
+ <soap:operation soapAction=""/>
+ <input>
+ <soap:body use="literal"/>
+ </input>
+ </operation>
+ </binding>
+ <service name="To">
+ <port name="ToPort" binding="tns:ToPortBinding">
+ <soap:address location="REPLACE_WITH_ACTUAL_URL"/>
+ </port>
+ </service>
+</definitions>
+
diff --git a/tests/org.eclipse.bpel.ui.tests/resources/wsdls/test3/readme.txt b/tests/org.eclipse.bpel.ui.tests/resources/wsdls/test3/readme.txt
new file mode 100644
index 0000000..b6e11c6
--- /dev/null
+++ b/tests/org.eclipse.bpel.ui.tests/resources/wsdls/test3/readme.txt
@@ -0,0 +1 @@
+Simple WSDL 1.1 with a XML schema import.
\ No newline at end of file
diff --git a/tests/org.eclipse.bpel.ui.tests/src/org/eclipse/bpel/ui/wizards/TestNewBpelFileWizard.java b/tests/org.eclipse.bpel.ui.tests/src/org/eclipse/bpel/ui/wizards/TestNewBpelFileWizard.java
new file mode 100644
index 0000000..f6c16c5
--- /dev/null
+++ b/tests/org.eclipse.bpel.ui.tests/src/org/eclipse/bpel/ui/wizards/TestNewBpelFileWizard.java
@@ -0,0 +1,441 @@
+/******************************************************************************
+ * Copyright (c) 2011, EBM WebSourcing
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * EBM WebSourcing - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.bpel.ui.wizards;
+
+import java.net.URL;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
+import org.eclipse.swtbot.swt.finder.SWTBot;
+import org.eclipse.swtbot.swt.finder.waits.ICondition;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu;
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ * A set of tests for the BPEL creation wizard.
+ * @author Vincent Zurczak - EBM WebSourcing
+ */
+public class TestNewBpelFileWizard {
+
+ private static final String BPEL_DIR = "bpelContent";
+ private static final String BPEL_NAME = "myProcess";
+ private static final String BPEL_FILE_NAME = BPEL_NAME + ".bpel";
+
+ private final SWTWorkbenchBot bot = new SWTWorkbenchBot();
+
+
+ /**
+ * Tests the creation of a BPEL from a template.
+ * <p>
+ * The process is created in the "bpelContent" directory of a BPEL project.
+ * </p>
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testTemplateInBpelDirectory() throws Exception {
+
+ // Test all the templates in a same method
+ for( int tplIndex=0; tplIndex<3; tplIndex++ ) {
+
+ try {
+ String projectName = createBpelProject( tplIndex );
+ SWTBotMenu newMenu = this.bot.menu( "File" ).menu( "New" );
+ newMenu.menu( "BPEL Process File" ).click();
+
+ this.bot.text( 0 ).setText( BPEL_NAME );
+ this.bot.comboBox( 1 ).setText( "http://" + BPEL_NAME );
+ this.bot.button( "Next >" ).click();
+
+ this.bot.comboBox( 0 ).setSelection( tplIndex );
+ this.bot.button( "Next >" ).click();
+
+ completeBpelFileCreation( true, projectName );
+ IPath path = new Path( projectName ).append( BPEL_DIR ).append( BPEL_FILE_NAME );
+ IFile bpelFile = ResourcesPlugin.getWorkspace().getRoot().getFile( path );
+ Assert.assertTrue( bpelFile.isAccessible());
+
+ // The empty template is not valid because it does not start with an starting activity
+ if( tplIndex == 1 )
+ Assert.assertEquals( bpelFile.findMarkers( null, true, IResource.DEPTH_ZERO ).length, 1 );
+ else
+ Assert.assertEquals( bpelFile.findMarkers( null, true, IResource.DEPTH_ZERO ).length, 0 );
+
+ } catch( AssertionError e ) {
+ String tplName = getTemplateName( tplIndex );
+ throw new AssertionError( "The " + tplName + " test failed. " + e.getMessage());
+ }
+ }
+ }
+
+
+ /**
+ * Tests the creation of a BPEL from a template.
+ * <p>
+ * The process is created at the root of a BPEL project.
+ * </p>
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testTemplateInBpelProject() throws Exception {
+
+ // Test all the templates in a same method
+ for( int tplIndex=0; tplIndex<3; tplIndex++ ) {
+
+ try {
+ String projectName = createBpelProject( tplIndex );
+ SWTBotMenu newMenu = this.bot.menu( "File" ).menu( "New" );
+ newMenu.menu( "BPEL Process File" ).click();
+
+ this.bot.text( 0 ).setText( BPEL_NAME );
+ this.bot.comboBox( 1 ).setText( "http://" + BPEL_NAME );
+ this.bot.button( "Next >" ).click();
+
+ this.bot.comboBox( 0 ).setSelection( tplIndex );
+ this.bot.button( "Next >" ).click();
+
+ completeBpelFileCreation( true, projectName );
+ IPath path = new Path( projectName ).append( BPEL_FILE_NAME );
+ IFile bpelFile = ResourcesPlugin.getWorkspace().getRoot().getFile( path );
+ Assert.assertTrue( bpelFile.isAccessible());
+
+ // The empty template is not valid because it does not start with an starting activity
+ if( tplIndex == 1 )
+ Assert.assertEquals( bpelFile.findMarkers( null, true, IResource.DEPTH_ZERO ).length, 1 );
+ else
+ Assert.assertEquals( bpelFile.findMarkers( null, true, IResource.DEPTH_ZERO ).length, 0 );
+
+ } catch( AssertionError e ) {
+ String tplName = getTemplateName( tplIndex );
+ throw new AssertionError( "The " + tplName + " test failed. " + e.getMessage());
+ }
+ }
+ }
+
+
+ /**
+ * Tests the creation of a BPEL from a template.
+ * <p>
+ * The process is created at the root of a non-BPEL project.
+ * </p>
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testTemplateInNonBpelProject() throws Exception {
+
+ // Test all the templates in a same method
+ for( int tplIndex=0; tplIndex<3; tplIndex++ ) {
+
+ try {
+ String projectName = createSimpleProject( tplIndex );
+ SWTBotMenu newMenu = this.bot.menu( "File" ).menu( "New" );
+ newMenu.menu( "BPEL Process File" ).click();
+
+ this.bot.text( 0 ).setText( BPEL_NAME );
+ this.bot.comboBox( 1 ).setText( "http://" + BPEL_NAME );
+ this.bot.button( "Next >" ).click();
+
+ this.bot.comboBox( 0 ).setSelection( tplIndex );
+ this.bot.button( "Next >" ).click();
+
+ completeBpelFileCreation( true, projectName );
+ IPath path = new Path( projectName ).append( BPEL_FILE_NAME );
+ IFile bpelFile = ResourcesPlugin.getWorkspace().getRoot().getFile( path );
+ Assert.assertTrue( bpelFile.isAccessible());
+
+ // The empty template is not valid because it does not start with an starting activity
+ if( tplIndex == 1 )
+ Assert.assertEquals( bpelFile.findMarkers( null, true, IResource.DEPTH_ZERO ).length, 1 );
+ else
+ Assert.assertEquals( bpelFile.findMarkers( null, true, IResource.DEPTH_ZERO ).length, 0 );
+
+ } catch( AssertionError e ) {
+ String tplName = getTemplateName( tplIndex );
+ throw new AssertionError( "The " + tplName + " test failed. " + e.getMessage());
+ }
+ }
+ }
+
+
+ /**
+ * Tests the creation of a BPEL from a template.
+ * <p>
+ * The process is created in the "bpelContent" directory of a BPEL project.
+ * The created process is abstract.
+ * </p>
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testTemplateAsAbstract() throws Exception {
+
+ // Test all the templates in a same method
+ for( int tplIndex=0; tplIndex<3; tplIndex++ ) {
+
+ try {
+ String projectName = createBpelProject( tplIndex );
+ SWTBotMenu newMenu = this.bot.menu( "File" ).menu( "New" );
+ newMenu.menu( "BPEL Process File" ).click();
+
+ this.bot.text( 0 ).setText( BPEL_NAME );
+ this.bot.comboBox( 1 ).setText( "http://" + BPEL_NAME );
+ this.bot.button( 0 ).click(); // Abstract
+ this.bot.button( "Next >" ).click();
+
+ this.bot.comboBox( 0 ).setSelection( tplIndex );
+ this.bot.button( "Next >" ).click();
+
+ completeBpelFileCreation( true, projectName );
+ IPath path = new Path( projectName ).append( BPEL_DIR ).append( BPEL_FILE_NAME );
+ IFile bpelFile = ResourcesPlugin.getWorkspace().getRoot().getFile( path );
+ Assert.assertTrue( bpelFile.isAccessible());
+
+ // The empty template is valid because the process is abstract
+ Assert.assertEquals( bpelFile.findMarkers( null, true, IResource.DEPTH_ZERO ).length, 0 );
+
+ } catch( AssertionError e ) {
+ String tplName = getTemplateName( tplIndex );
+ throw new AssertionError( "The " + tplName + " test failed. " + e.getMessage());
+ }
+ }
+ }
+
+
+ /**
+ * Tests the creation of a BPEL from a WSDL definition.
+ * <p>
+ * The WSDL is imported in the project.
+ * The process is created in the "bpelContent" directory of a BPEL project.
+ * </p>
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testGenerationFromWsdlWithImport() throws Exception {
+
+ String[] wsdlFiles = { "test1/tuxDroid.wsdl", "test2/tuxDroid.wsdl", "test3/To.wsdl" };
+ for( int index=0; index<wsdlFiles.length; index++ ) {
+
+ String wsdlFile = wsdlFiles[ index ];
+ try {
+ URL url = getClass().getResource( "/wsdls/" + wsdlFile );
+ String projectName = createBpelProject( index );
+ SWTBotMenu newMenu = this.bot.menu( "File" ).menu( "New" );
+ newMenu.menu( "BPEL Process File" ).click();
+
+ this.bot.comboBox().setSelection( 1 );
+ this.bot.text( 0 ).setText( BPEL_NAME );
+ this.bot.comboBox( 1 ).setText( "http://" + BPEL_NAME );
+ this.bot.button( "Next >" ).click();
+
+ this.bot.text( 0 ).setText( url.toString());
+ this.bot.comboBox( 0 ).setSelection( 0 );
+ this.bot.button( "Next >" ).click();
+
+ completeBpelFileCreation( true, projectName );
+ IPath path = new Path( projectName ).append( BPEL_FILE_NAME );
+ IFile bpelFile = ResourcesPlugin.getWorkspace().getRoot().getFile( path );
+ Assert.assertTrue( bpelFile.isAccessible());
+ Assert.assertEquals( bpelFile.findMarkers( null, true, IResource.DEPTH_ZERO ).length, 0 );
+
+ } catch( AssertionError e ) {
+ throw new AssertionError( "The creation with " + wsdlFile + " failed. " + e.getMessage());
+ }
+ }
+ }
+
+
+ /**
+ * Tests the creation of a BPEL from a WSDL definition.
+ * <p>
+ * The WSDL is not imported in the project.
+ * The process is created in the "bpelContent" directory of a BPEL project.
+ * </p>
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testGenerationFromWsdlWithoutImport() throws Exception {
+
+ String[] wsdlFiles = { "test1/tuxDroid.wsdl", "test2/tuxDroid.wsdl", "test3/To.wsdl" };
+ for( int index=0; index<wsdlFiles.length; index++ ) {
+
+ String wsdlFile = wsdlFiles[ index ];
+ try {
+ URL url = getClass().getResource( "/wsdls/" + wsdlFile );
+ String projectName = createBpelProject( index );
+ SWTBotMenu newMenu = this.bot.menu( "File" ).menu( "New" );
+ newMenu.menu( "BPEL Process File" ).click();
+
+ this.bot.comboBox().setSelection( 1 );
+ this.bot.text( 0 ).setText( BPEL_NAME );
+ this.bot.comboBox( 1 ).setText( "http://" + BPEL_NAME );
+ this.bot.button( "Next >" ).click();
+
+ this.bot.text( 0 ).setText( url.toString());
+ this.bot.comboBox( 0 ).setSelection( 0 );
+ this.bot.button( 0 ).click(); // Do not import the WSDL
+ this.bot.button( "Next >" ).click();
+
+ completeBpelFileCreation( true, projectName );
+ IPath path = new Path( projectName ).append( BPEL_FILE_NAME );
+ IFile bpelFile = ResourcesPlugin.getWorkspace().getRoot().getFile( path );
+ Assert.assertTrue( bpelFile.isAccessible());
+ Assert.assertEquals( bpelFile.findMarkers( null, true, IResource.DEPTH_ZERO ).length, 0 );
+
+ } catch( AssertionError e ) {
+ throw new AssertionError( "The creation with " + wsdlFile + " failed. " + e.getMessage());
+ }
+ }
+ }
+
+
+ /**
+ * Tests the creation of a BPEL from a WSDL definition.
+ * <p>
+ * The WSDL is imported in the project.
+ * The process is created in the "bpelContent" directory of a BPEL project.
+ * The created process is abstract.
+ * </p>
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testGenerationFromWsdlAsAbstract() throws Exception {
+
+ String[] wsdlFiles = { "test1/tuxDroid.wsdl", "test2/tuxDroid.wsdl", "test3/To.wsdl" };
+ for( int index=0; index<wsdlFiles.length; index++ ) {
+
+ String wsdlFile = wsdlFiles[ index ];
+ try {
+ URL url = getClass().getResource( "/wsdls/" + wsdlFile );
+ String projectName = createBpelProject( index );
+ SWTBotMenu newMenu = this.bot.menu( "File" ).menu( "New" );
+ newMenu.menu( "BPEL Process File" ).click();
+
+ this.bot.comboBox().setSelection( 1 );
+ this.bot.text( 0 ).setText( BPEL_NAME );
+ this.bot.comboBox( 1 ).setText( "http://" + BPEL_NAME );
+ this.bot.button( 0 ).click(); // Abstract
+ this.bot.button( "Next >" ).click();
+
+ this.bot.text( 0 ).setText( url.toString());
+ this.bot.comboBox( 0 ).setSelection( 0 );
+ this.bot.button( "Next >" ).click();
+
+ completeBpelFileCreation( true, projectName );
+ IPath path = new Path( projectName ).append( BPEL_FILE_NAME );
+ IFile bpelFile = ResourcesPlugin.getWorkspace().getRoot().getFile( path );
+ Assert.assertTrue( bpelFile.isAccessible());
+ Assert.assertEquals( bpelFile.findMarkers( null, true, IResource.DEPTH_ZERO ).length, 0 );
+
+ } catch( AssertionError e ) {
+ throw new AssertionError( "The creation with " + wsdlFile + " failed. " + e.getMessage());
+ }
+ }
+ }
+
+
+ /**
+ * Gets the name of the template associated with this index.
+ * @param templateIndex the template index
+ * @return the template name (or "Unknown" is it does not match anything)
+ */
+ private String getTemplateName( int templateIndex ) {
+
+ String tplName;
+ switch( templateIndex ) {
+ case 0: tplName = "Asynchronous"; break;
+ case 1: tplName = "Empty"; break;
+ case 2: tplName = "Synchronous"; break;
+ default: tplName = "Unknwon"; break;
+ }
+
+ return tplName;
+ }
+
+
+ /**
+ * Completes the creation of a new BPEL file.
+ * @param selectBpelDir true to create the BPEL in the {@link #BPEL_DIR} directory, false for the root of the project
+ * @param projectName the project name
+ */
+ private void completeBpelFileCreation( boolean selectBpelDir, String projectName ) {
+
+ if( selectBpelDir )
+ this.bot.tree( 0 ).select( projectName ).expandNode( projectName ).select( BPEL_DIR );
+ else
+ this.bot.tree( 0 ).select( projectName );
+
+ this.bot.button( "Finish" ).click();
+ this.bot.waitUntil( new ICondition() {
+
+ @Override
+ public boolean test() throws Exception {
+ String title = TestNewBpelFileWizard.this.bot.activeEditor().getTitle();
+ return (BPEL_NAME + ".bpel").equals( title );
+ }
+
+ @Override
+ public void init( SWTBot bot ) {
+ // nothing
+ }
+
+ @Override
+ public String getFailureMessage() {
+ return "Could not wait for the BPEL Designer to be open";
+ }
+ });
+ }
+
+
+ /**
+ * Creates a BPEL project.
+ * @param projectNameSuffix the suffix for the project name
+ * @return the project name
+ */
+ private String createBpelProject( Object projectNameSuffix ) {
+
+ String projectName = "TestProject" + String.valueOf( projectNameSuffix );
+ SWTBotMenu newMenu = this.bot.menu( "File" ).menu( "New" );
+ newMenu.menu( "BPEL Project" ).click();
+ this.bot.text( 0 ).setText( projectName );
+ this.bot.button( "Next >" ).click();
+ this.bot.button( "Finish" ).click();
+
+ return projectName;
+ }
+
+
+ /**
+ * Creates a simple project.
+ * @param projectNameSuffix the suffix for the project name
+ * @return the project name
+ */
+ private String createSimpleProject( Object projectNameSuffix ) {
+
+ String projectName = "TestProject" + String.valueOf( projectNameSuffix );
+ SWTBotMenu newMenu = this.bot.menu( "File" ).menu( "New" );
+ newMenu.menu( "Project" ).click();
+ this.bot.text( 0 ).setText( projectName );
+ this.bot.button( "Finish" ).click();
+
+ return projectName;
+ }
+}
diff --git a/tests/pom.xml b/tests/pom.xml
new file mode 100644
index 0000000..047d02c
--- /dev/null
+++ b/tests/pom.xml
@@ -0,0 +1,20 @@
+<project
+xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.eclipse</groupId>
+ <artifactId>bpel</artifactId>
+ <name>bpel.all</name>
+ <version>0.0.1-SNAPSHOT</version>
+ <packaging>pom</packaging>
+ <modules>
+ <!-- must build parent BEFORE building the rest of this project
+ <module>parent</module> -->
+
+ <module>plugins</module>
+ <module>tests</module>
+ <!-- <module>examples></module> -->
+ <module>features</module>
+ <module>site</module>
+ </modules>
+</project>
+