Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 59774 Details for
Bug 165544
WSDM Tooling: Enhanced importing of WSDLs and schemas
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Updated patch
ImportWsdlPatch.txt (text/plain), 15.13 KB, created by
Saurabh Dravid
on 2007-02-26 07:02:21 EST
(
hide
)
Description:
Updated patch
Filename:
MIME Type:
Creator:
Saurabh Dravid
Created:
2007-02-26 07:02:21 EST
Size:
15.13 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.tptp.wsdm.model >Index: src/org/eclipse/tptp/wsdm/model/WSDLDefinition.java >=================================================================== >RCS file: /cvsroot/ganges/org.eclipse.tptp.wsdm.model/src/org/eclipse/tptp/wsdm/model/WSDLDefinition.java,v >retrieving revision 1.1 >diff -u -r1.1 WSDLDefinition.java >--- src/org/eclipse/tptp/wsdm/model/WSDLDefinition.java 8 Feb 2007 19:41:08 -0000 1.1 >+++ src/org/eclipse/tptp/wsdm/model/WSDLDefinition.java 26 Feb 2007 11:51:48 -0000 >@@ -31,8 +31,11 @@ > 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.xsd.XSDFactory; > import org.eclipse.xsd.XSDSchema; >+import org.eclipse.xsd.impl.XSDSchemaImpl; > import org.eclipse.xsd.util.XSDResourceFactoryImpl; >+import org.w3c.dom.Element; > > /** > * Its a wrapper class for WSDL4j Definition object. >@@ -362,4 +365,43 @@ > } > return (XSDSchema[]) schemas.toArray(new XSDSchema[0]); > } >+ >+ public void addSchema(Element schemaElement, Map namespacesMap) >+ { >+ XSDSchema schema = XSDFactory.eINSTANCE.createXSDSchema(); >+ schema.setElement(schemaElement); >+ if(namespacesMap!=null) >+ { >+ Iterator keyIt = namespacesMap.keySet().iterator(); >+ while(keyIt.hasNext()) >+ { >+ String prefix = (String) keyIt.next(); >+ String namespace = (String) namespacesMap.get(prefix); >+ if(!namespace.equals("http://www.w3.org/2001/XMLSchema")) >+ if(!isPrefixDeclared(schema, prefix)) >+ schema.getQNamePrefixToNamespaceMap().put(prefix, namespace); >+ } >+ } >+ schema.updateElement(true); >+ namespacesMap = schema.getQNamePrefixToNamespaceMap(); >+ if(namespacesMap!=null) >+ { >+ Iterator keyIt = namespacesMap.keySet().iterator(); >+ while(keyIt.hasNext()) >+ { >+ String prefix = (String) keyIt.next(); >+ String namespace = (String) namespacesMap.get(prefix); >+ if(prefix!=null) >+ if(!namespace.equals("http://www.w3.org/2001/XMLSchema")) >+ schema.getElement().setAttribute("xmlns:"+prefix, namespace); >+ } >+ } >+ _definedSchemaList.add(schema); >+ } >+ >+ private boolean isPrefixDeclared(XSDSchema schema, String prefix) >+ { >+ Map namespacesMap = schema.getQNamePrefixToNamespaceMap(); >+ return namespacesMap.get(prefix)!=null; >+ } > } >#P org.eclipse.tptp.wsdm.editor >Index: src/org/eclipse/tptp/wsdm/tooling/editor/capability/imports/wsdl/XSDSchemaMerger.java >=================================================================== >RCS file: src/org/eclipse/tptp/wsdm/tooling/editor/capability/imports/wsdl/XSDSchemaMerger.java >diff -N src/org/eclipse/tptp/wsdm/tooling/editor/capability/imports/wsdl/XSDSchemaMerger.java >--- src/org/eclipse/tptp/wsdm/tooling/editor/capability/imports/wsdl/XSDSchemaMerger.java 13 Feb 2007 14:31:44 -0000 1.2 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,108 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2007 IBM 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: >- * Balan Subramanian (bsubram@us.ibm.com) >- * IBM Corporation - initial API and implementation >- *******************************************************************************/ >- >-package org.eclipse.tptp.wsdm.tooling.editor.capability.imports.wsdl; >- >-import java.util.LinkedList; >-import java.util.List; >- >-import org.eclipse.tptp.wsdm.tooling.util.internal.XsdUtils; >-import org.eclipse.xsd.XSDImport; >-import org.eclipse.xsd.XSDInclude; >-import org.eclipse.xsd.XSDSchema; >- >-/** >- * This merges the given XSD Schema and returns the array of new schemas.<br> >- * Array contains the original XSD schema and all the Imported schemas.<br> >- * All the included schmeas merged into original schema. >- * >- */ >- >-public class XSDSchemaMerger >-{ >- >- private XSDSchema _schema; >- private List _allResultedSchema; >- private List _allAddedSchemaURIs; >- >- public XSDSchemaMerger(XSDSchema schema) >- { >- _schema = schema; >- _allResultedSchema = new LinkedList(); >- _allAddedSchemaURIs = new LinkedList(); >- addSchema(_schema); >- } >- >- public XSDSchema[] merge() >- { >- XSDImport[] imports = XsdUtils.getAllXSDImports(_schema); >- for (int i = 0; i < imports.length; i++) >- { >- if (imports[i].getResolvedSchema() == null) >- continue; >- addSchema(imports[i].getResolvedSchema()); >- XSDSchemaMerger merger = new XSDSchemaMerger(imports[i] >- .getResolvedSchema()); >- XSDSchema[] schemas = merger.merge(); >- for (int j = 0; j < schemas.length; j++) >- addSchema(schemas[j]); >- } >- >- XSDInclude[] includes = XsdUtils.getAllXSDIncludes(_schema); >- for (int i = 0; i < includes.length; i++) >- { >- if (includes[i].getResolvedSchema() == null) >- continue; >- addSchema(includes[i].getResolvedSchema()); >- XSDSchemaMerger merger = new XSDSchemaMerger(includes[i] >- .getResolvedSchema()); >- XSDSchema[] schemas = merger.merge(); >- for (int j = 0; j < schemas.length; j++) >- addSchema(schemas[j]); >- } >- >- return (XSDSchema[]) _allResultedSchema >- .toArray(new XSDSchema[_allResultedSchema.size()]); >- } >- >- private void addSchema(XSDSchema givenSchema) >- { >- if(isAlreadyAdded(givenSchema)) >- return; >- XSDSchema clonedSchema = (XSDSchema) givenSchema.cloneConcreteComponent(true, true); >- clonedSchema.setSchemaLocation(givenSchema.getSchemaLocation()); >- XSDSchema schema = getSchema(clonedSchema.getTargetNamespace()); >- if (schema != null) >- schema.getContents().addAll(clonedSchema.getContents()); >- else >- _allResultedSchema.add(clonedSchema); >- String schemaLocation = clonedSchema.getSchemaLocation(); >- _allAddedSchemaURIs.add(schemaLocation); >- } >- >- private boolean isAlreadyAdded(XSDSchema givenSchema) >- { >- String schemaLocation = givenSchema.getSchemaLocation(); >- return _allAddedSchemaURIs.contains(schemaLocation); >- } >- >- private XSDSchema getSchema(String targetNamespace) >- { >- for (int i = 0; i < _allResultedSchema.size(); i++) >- { >- XSDSchema schema = (XSDSchema) _allResultedSchema.get(i); >- if (schema.getTargetNamespace().equals(targetNamespace)) >- return schema; >- } >- return null; >- } >-} >Index: src/org/eclipse/tptp/wsdm/tooling/editor/capability/command/operation/internal/ImportOperationCommand.java >=================================================================== >RCS file: /cvsroot/ganges/org.eclipse.tptp.wsdm.editor/src/org/eclipse/tptp/wsdm/tooling/editor/capability/command/operation/internal/ImportOperationCommand.java,v >retrieving revision 1.2 >diff -u -r1.2 ImportOperationCommand.java >--- src/org/eclipse/tptp/wsdm/tooling/editor/capability/command/operation/internal/ImportOperationCommand.java 13 Feb 2007 14:31:44 -0000 1.2 >+++ src/org/eclipse/tptp/wsdm/tooling/editor/capability/command/operation/internal/ImportOperationCommand.java 26 Feb 2007 11:51:51 -0000 >@@ -12,17 +12,13 @@ > > package org.eclipse.tptp.wsdm.tooling.editor.capability.command.operation.internal; > >-import java.util.ArrayList; >-import java.util.Arrays; > import java.util.Iterator; > import java.util.LinkedList; > import java.util.List; > import java.util.Map; >-import java.util.Vector; > > import javax.wsdl.Definition; > import javax.wsdl.Fault; >-import javax.wsdl.Import; > import javax.wsdl.Input; > import javax.wsdl.Message; > import javax.wsdl.Operation; >@@ -31,24 +27,21 @@ > import javax.wsdl.PortType; > import javax.xml.namespace.QName; > >+import org.apache.muse.core.Environment; >+import org.apache.muse.util.xml.XmlUtils; > import org.eclipse.core.runtime.IProgressMonitor; > import org.eclipse.core.runtime.NullProgressMonitor; >-import org.eclipse.emf.common.util.EList; > 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.tptp.wsdm.tooling.editor.capability.imports.wsdl.XSDSchemaMerger; >+import org.eclipse.tptp.wsdm.tooling.codegen.mrt.provisional.EclipseEnvironment; > import org.eclipse.tptp.wsdm.tooling.editor.internal.CapabilityDefinition; > import org.eclipse.tptp.wsdm.tooling.nls.messages.capability.imports.internal.Messages; > import org.eclipse.tptp.wsdm.tooling.util.internal.WsdlUtils; > import org.eclipse.tptp.wsdm.tooling.util.internal.WsdmConstants; > import org.eclipse.tptp.wsdm.tooling.util.internal.XsdUtils; > import org.eclipse.xsd.XSDElementDeclaration; >-import org.eclipse.xsd.XSDImport; >-import org.eclipse.xsd.XSDInclude; > import org.eclipse.xsd.XSDSchema; >-import org.eclipse.xsd.util.XSDResourceFactoryImpl; >+import org.w3c.dom.Document; >+import org.w3c.dom.Element; > > /** > * Command class to import operations into the capability. >@@ -64,7 +57,6 @@ > private URI _importedWsdlURI; > private List _newOperations; > private IProgressMonitor _monitor; >- private XSDSchema[] _importedWsdlSchemas = new XSDSchema[0]; > private QName WSA_ACTION_QNAME = new QName(WsdmConstants.WSA_URI, > WsdmConstants.WSA_ACTION_NAME); > >@@ -81,7 +73,6 @@ > _importedOperations = importedOperations; > _newOperations = new LinkedList(); > _monitor = monitor; >- _importedWsdlSchemas = loadSchemas(); > //XSDSchema[] capabilityWsdlSchemas = _capabilityDefinition.getXSDSchemas(); > // TODO > /* >@@ -112,6 +103,7 @@ > _importedOperations.length); > _definition.addNamespace(WsdmConstants.WSA_PREFIX, > WsdmConstants.WSA_URI); >+ createMergeWsdlForImportedWsdl(); > for (int i = 0; i < _importedOperations.length; i++) > { > String taskName = Messages.bind(Messages.IMPORTING_OPERATION, >@@ -224,8 +216,6 @@ > part.setName(importedPart.getName()); > if(importedPart.getElementName()!=null) > { >- XSDSchema importedPartSchema = getImportedWSDLSchema(importedPart.getElementName().getNamespaceURI()); >- importSchemaForElement(importedPartSchema); > String xsdNS = importedPart.getElementName().getNamespaceURI(); > String elementName = importedPart.getElementName().getLocalPart(); > XSDSchema elementSchema = _capabilityDefinition.getSchema(xsdNS); >@@ -242,130 +232,26 @@ > return message; > } > >- private XSDSchema getImportedWSDLSchema(String namespace) >- { >- for(int i=0;i<_importedWsdlSchemas.length;i++) >- if(_importedWsdlSchemas[i].getTargetNamespace().equals(namespace)) >- return _importedWsdlSchemas[i]; >- >- for(int i=0;i<_importedWsdlSchemas.length;i++) >- { >- XSDImport theImports[] = XsdUtils.getAllXSDImports(_importedWsdlSchemas[i]); >- for(int j=0;j<theImports.length;j++) >- if(theImports[j].getNamespace().equals(namespace)) >- return theImports[j].getResolvedSchema(); >- } >- return null; >- } >- >- private void importSchemaForElement(XSDSchema elementSchema) >- { >- XSDSchemaMerger merger = new XSDSchemaMerger(elementSchema); >- XSDSchema[] mergedSchemas = merger.merge(); >- for(int i=0;i<mergedSchemas.length;i++) >- { >- if(!isSchemaExistsInWsdl(mergedSchemas[i])) >- { >- XSDSchema copySchema = createCopy(mergedSchemas[i]); >- XSDSchema schema = _capabilityDefinition.createOrFindSchema(copySchema.getTargetNamespace()); >- schema.setElement(copySchema.getElement()); >- schema.updateElement(true); >- } >- } >- } >- >- private boolean isSchemaExistsInWsdl(XSDSchema schema) >- { >- XSDSchema wsdlSchema = _capabilityDefinition.getSchema(schema >- .getTargetNamespace()); >- if (wsdlSchema != null) >- return true; >- return false; >- } >- >- private XSDSchema createCopy(XSDSchema schema) >- { >- XSDSchema copySchema = (XSDSchema) schema.cloneConcreteComponent(true, >- false); >- List contents = copySchema.getContents(); >- List includes = new LinkedList(); >- List imports = new LinkedList(); >- for (int i = 0; i < contents.size(); i++) >- { >- if (contents.get(i) instanceof XSDInclude) >- includes.add(contents.get(i)); >- else if (contents.get(i) instanceof XSDImport) >- { >- XSDImport theImport = (XSDImport) contents.get(i); >- theImport.setSchemaLocation(null); >- imports.add(theImport); >- } >- } >- contents.removeAll(includes); >- contents.removeAll(imports); >- contents.addAll(0, imports); >- copySchema.updateElement(true); >- return copySchema; >- } >- > public Operation[] getNewOperations() > { > return (Operation[]) _newOperations > .toArray(new Operation[_newOperations.size()]); > } > >- private XSDSchema[] loadSchemas() >- { >- List schemasList = new LinkedList(); >- XSDSchema[] schemas = loadSchemas(_importedWsdlURI); >- schemasList.addAll(Arrays.asList(schemas)); >- >- Map importsMap = _importDefinition.getImports(); >- if(importsMap == null || importsMap.size() == 0) >- return (XSDSchema[]) schemasList.toArray(new XSDSchema[0]); >- >- Iterator it = importsMap.values().iterator(); >- while(it.hasNext()) >- { >- Object object = it.next(); >- if(object instanceof Vector) >- { >- Vector vector = (Vector) object; >- for(int i=0;i<vector.size();i++) >- { >- Import wsdlImport = (Import) vector.get(i); >- String locationURI = wsdlImport.getLocationURI(); >- URI wsdlURI = URI.createURI(_importedWsdlURI.trimSegments(1).toString()+"/"+locationURI); >- XSDSchema[] importedSchemas = loadSchemas(wsdlURI); >- schemasList.addAll(Arrays.asList(importedSchemas)); >- } >- } >- } >- >- return (XSDSchema[]) schemasList.toArray(new XSDSchema[0]); >- } >- >- private XSDSchema[] loadSchemas(URI uri) >+ private void createMergeWsdlForImportedWsdl() > { >- // Get a ResourceSet describing the XSD in the WSDL >- XSDSchema schema = null; >- ResourceSet resourceSet = new ResourceSetImpl(); >- Resource resourceWsdl = null; >- resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap() >- .put("*", new XSDResourceFactoryImpl()); >- resourceWsdl = resourceSet.getResource(uri, true); >- EList list = resourceWsdl.getContents(); >- >- List schemas = new ArrayList(); >- for (int i = 0; i < list.size(); i++) >- { >- Object o = list.get(i); >- if (o instanceof XSDSchema) >- { >- schema = (XSDSchema) o; >- schemas.add(schema); >- } >- } >- return (XSDSchema[]) schemas.toArray(new XSDSchema[0]); >+ Environment env = new EclipseEnvironment(); >+ String wsdlPath = _importedWsdlURI.toString(); >+ Document mergedWsdl = org.apache.muse.ws.wsdl.WsdlUtils.createWSDL(env, wsdlPath, true); >+ Element root = XmlUtils.getFirstElement(mergedWsdl); >+ org.apache.muse.ws.wsdl.WsdlUtils.removeWsdlReferences(root); >+ org.apache.muse.ws.wsdl.WsdlUtils.removeSchemaReferences(root); >+ Element types = XmlUtils.getElement(root, org.apache.muse.ws.wsdl.WsdlUtils.TYPES_QNAME); >+ Element[] schemas = XmlUtils.getElements(types, org.apache.muse.util.xml.XsdUtils.SCHEMA_QNAME); >+ Map namespacesMap = _importDefinition.getNamespaces(); >+ for(int i=0;i<schemas.length;i++) >+ { >+ _capabilityDefinition.addSchema(schemas[i], namespacesMap); >+ } > } > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 165544
:
58038
|
58095
|
58849
|
59774
|
64199