Removing the deprecated gfac schemas from the repo - AIRAVATA-1699
Project: http://git-wip-us.apache.org/repos/asf/airavata/repo Commit: http://git-wip-us.apache.org/repos/asf/airavata/commit/febe2f92 Tree: http://git-wip-us.apache.org/repos/asf/airavata/tree/febe2f92 Diff: http://git-wip-us.apache.org/repos/asf/airavata/diff/febe2f92 Branch: refs/heads/master Commit: febe2f925a67e8c8ac3ed63e202340a3c3f889a4 Parents: a893d86 Author: Suresh Marru <[email protected]> Authored: Tue May 12 17:12:19 2015 -0400 Committer: Suresh Marru <[email protected]> Committed: Tue May 12 17:12:19 2015 -0400 ---------------------------------------------------------------------- modules/commons/gfac-schema/pom.xml | 111 ---- .../commons/gfac/type/ActualParameter.java | 72 --- .../gfac/type/ApplicationDescription.java | 59 -- .../commons/gfac/type/HostDescription.java | 56 -- .../commons/gfac/type/MappingFactory.java | 184 ------ .../commons/gfac/type/ServiceDescription.java | 51 -- .../apache/airavata/commons/gfac/type/Type.java | 27 - .../commons/gfac/wsdl/GFacSchemaConstants.java | 119 ---- .../commons/gfac/wsdl/GFacWSDLException.java | 43 -- .../airavata/commons/gfac/wsdl/RoundTrip.java | 141 ----- .../commons/gfac/wsdl/TypesGenerator.java | 281 --------- .../commons/gfac/wsdl/WSDLConstants.java | 106 ---- .../commons/gfac/wsdl/WSDLGenerator.java | 583 ------------------- .../commons/gfac/wsdl/WSDLGeneratorUtil.java | 52 -- .../commons/gfac/wsdl/WSDLMessageBean.java | 211 ------- .../commons/gfac/wsdl/WSPolicyGenerator.java | 152 ----- .../src/main/resources/datatype.properties | 31 - .../ApplicationDeploymentDescription.xsd | 141 ----- .../src/main/resources/schemas/BasicTypes.xsd | 51 -- .../resources/schemas/GFacParameterTypes.xsd | 248 -------- .../main/resources/schemas/HostDescription.xsd | 196 ------- .../resources/schemas/ServiceDescription.xsd | 95 --- .../resources/schemas/gfac-schemas.xsdconfig | 31 - .../commons/gfac/wsdl/TestWSDLGeneration.java | 132 ----- modules/commons/pom.xml | 2 - modules/distribution/server/pom.xml | 5 - modules/messaging/core/pom.xml | 5 - modules/registry/airavata-jpa-registry/pom.xml | 5 - modules/workflow-model/workflow-engine/pom.xml | 5 - 29 files changed, 3195 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/airavata/blob/febe2f92/modules/commons/gfac-schema/pom.xml ---------------------------------------------------------------------- diff --git a/modules/commons/gfac-schema/pom.xml b/modules/commons/gfac-schema/pom.xml deleted file mode 100644 index c861e4f..0000000 --- a/modules/commons/gfac-schema/pom.xml +++ /dev/null @@ -1,111 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> - -<!--Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file - distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under - the Apache License, Version 2.0 (theà "License"); you may not use this file except in compliance with the License. You may - obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to - in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF - ANY ~ KIND, either express or implied. See the License for the specific language governing permissions and limitations under - the License. --> - -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> - - <parent> - <groupId>org.apache.airavata</groupId> - <artifactId>commons</artifactId> - <version>0.15-SNAPSHOT</version> - <relativePath>../pom.xml</relativePath> - </parent> - - <modelVersion>4.0.0</modelVersion> - <artifactId>airavata-gfac-schema-utils</artifactId> - <packaging>jar</packaging> - <name>Airavata GFac Schema Utilities</name> - <url>http://airavata.apache.org/</url> - - <dependencies> - <dependency> - <groupId>org.apache.airavata</groupId> - <artifactId>airavata-common-utils</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.apache.xmlbeans</groupId> - <artifactId>xmlbeans</artifactId> - <version>${xmlbeans.version}</version> - </dependency> - <dependency> - <groupId>wsdl4j</groupId> - <artifactId>wsdl4j</artifactId> - <version>1.6.2</version> - </dependency> - <dependency> - <groupId>org.ogce</groupId> - <artifactId>xpp3</artifactId> - <version>${xpp3.version}</version> - </dependency> - <dependency> - <groupId>org.slf4j</groupId> - <artifactId>slf4j-api</artifactId> - </dependency> - <!-- Testing --> - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.slf4j</groupId> - <artifactId>jcl-over-slf4j</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.slf4j</groupId> - <artifactId>slf4j-log4j12</artifactId> - <scope>test</scope> - </dependency> - </dependencies> - <build> - <plugins> - <plugin> - <groupId>org.codehaus.mojo</groupId> - <artifactId>build-helper-maven-plugin</artifactId> - <version>1.7</version> - <executions> - <execution> - <id>add-source</id> - <phase>generate-sources</phase> - <goals> - <goal>add-source</goal> - </goals> - <configuration> - <sources> - <source>${basedir}/target/generated-sources/xmlbeans</source> - </sources> - </configuration> - </execution> - </executions> - </plugin> - <plugin> - <groupId>org.codehaus.mojo</groupId> - <artifactId>xmlbeans-maven-plugin</artifactId> - <version>2.3.3</version> - <executions> - <execution> - <goals> - <goal>xmlbeans</goal> - </goals> - </execution> - </executions> - <inherited>true</inherited> - <configuration> - <schemaDirectory>src/main/resources/schemas</schemaDirectory> - <xmlConfigs> - <xmlConfig implementation="java.io.File">src/main/resources/schemas/gfac-schemas.xsdconfig</xmlConfig> - </xmlConfigs> - <outputJar>target/generated/${project.artifactId}-${project.version}.jar</outputJar> - </configuration> - </plugin> - </plugins> - </build> -</project> http://git-wip-us.apache.org/repos/asf/airavata/blob/febe2f92/modules/commons/gfac-schema/src/main/java/org/apache/airavata/commons/gfac/type/ActualParameter.java ---------------------------------------------------------------------- diff --git a/modules/commons/gfac-schema/src/main/java/org/apache/airavata/commons/gfac/type/ActualParameter.java b/modules/commons/gfac-schema/src/main/java/org/apache/airavata/commons/gfac/type/ActualParameter.java deleted file mode 100644 index e6e683a..0000000 --- a/modules/commons/gfac-schema/src/main/java/org/apache/airavata/commons/gfac/type/ActualParameter.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -package org.apache.airavata.commons.gfac.type; - -import org.apache.airavata.commons.gfac.type.Type; -import org.apache.airavata.schemas.gfac.DataType; -import org.apache.airavata.schemas.gfac.GFacParameterDocument; -import org.apache.airavata.schemas.gfac.ParameterType; -import org.apache.airavata.schemas.gfac.StringParameterType; -import org.apache.xmlbeans.SchemaType; -import org.apache.xmlbeans.XmlException; - -public class ActualParameter implements Type { - - private static final long serialVersionUID = -6022759981837350675L; - private GFacParameterDocument paramDoc; - - public ActualParameter() { - this.paramDoc = GFacParameterDocument.Factory.newInstance(); - this.paramDoc.addNewGFacParameter(); - - // default type is String - this.paramDoc.getGFacParameter().changeType(StringParameterType.type); - } - - public ActualParameter(SchemaType type) { - this.paramDoc = GFacParameterDocument.Factory.newInstance(); - this.paramDoc.addNewGFacParameter(); - this.paramDoc.getGFacParameter().changeType(type); - } - - public ParameterType getType() { - return this.paramDoc.getGFacParameter(); - } - - public boolean hasType(DataType.Enum type) { - return this.paramDoc.getGFacParameter().getType() == type; - } - - public String toXML() { - return this.paramDoc.xmlText(); - } - - public void setParamDoc(GFacParameterDocument paramDoc) { - this.paramDoc = paramDoc; - } - - public static ActualParameter fromXML(String xml) throws XmlException { - ActualParameter param = new ActualParameter(); - param.paramDoc = GFacParameterDocument.Factory.parse(xml); - return param; - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/airavata/blob/febe2f92/modules/commons/gfac-schema/src/main/java/org/apache/airavata/commons/gfac/type/ApplicationDescription.java ---------------------------------------------------------------------- diff --git a/modules/commons/gfac-schema/src/main/java/org/apache/airavata/commons/gfac/type/ApplicationDescription.java b/modules/commons/gfac-schema/src/main/java/org/apache/airavata/commons/gfac/type/ApplicationDescription.java deleted file mode 100644 index 1a12ca0..0000000 --- a/modules/commons/gfac-schema/src/main/java/org/apache/airavata/commons/gfac/type/ApplicationDescription.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -package org.apache.airavata.commons.gfac.type; - -import org.apache.airavata.schemas.gfac.ApplicationDeploymentDescriptionDocument; -import org.apache.airavata.schemas.gfac.ApplicationDeploymentDescriptionType; -import org.apache.xmlbeans.SchemaType; -import org.apache.xmlbeans.XmlException; - -public class ApplicationDescription implements Type { - - private ApplicationDeploymentDescriptionDocument appDocument; - - public ApplicationDescription() { - this.appDocument = ApplicationDeploymentDescriptionDocument.Factory - .newInstance(); - this.appDocument.addNewApplicationDeploymentDescription(); - } - - public ApplicationDescription(SchemaType type) { - this(); - this.appDocument.getApplicationDeploymentDescription().changeType(type); - } - - public ApplicationDeploymentDescriptionType getType() { - return this.appDocument.getApplicationDeploymentDescription(); - } - - public String toXML() { - return appDocument.xmlText(); - } - - public static ApplicationDescription fromXML(String xml) - throws XmlException { - ApplicationDescription app = new ApplicationDescription(); - app.appDocument = ApplicationDeploymentDescriptionDocument.Factory - .parse(xml); - return app; - } -} http://git-wip-us.apache.org/repos/asf/airavata/blob/febe2f92/modules/commons/gfac-schema/src/main/java/org/apache/airavata/commons/gfac/type/HostDescription.java ---------------------------------------------------------------------- diff --git a/modules/commons/gfac-schema/src/main/java/org/apache/airavata/commons/gfac/type/HostDescription.java b/modules/commons/gfac-schema/src/main/java/org/apache/airavata/commons/gfac/type/HostDescription.java deleted file mode 100644 index 813aae7..0000000 --- a/modules/commons/gfac-schema/src/main/java/org/apache/airavata/commons/gfac/type/HostDescription.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -package org.apache.airavata.commons.gfac.type; - -import org.apache.airavata.schemas.gfac.HostDescriptionDocument; -import org.apache.airavata.schemas.gfac.HostDescriptionType; -import org.apache.xmlbeans.SchemaType; -import org.apache.xmlbeans.XmlException; - -public class HostDescription implements Type { - - private HostDescriptionDocument hostDocument; - - public HostDescription() { - this.hostDocument = HostDescriptionDocument.Factory.newInstance(); - this.hostDocument.addNewHostDescription(); - } - - public HostDescription(SchemaType type) { - this(); - this.hostDocument.getHostDescription().changeType(type); - } - - public HostDescriptionType getType() { - return this.hostDocument.getHostDescription(); - } - - public String toXML() { - return hostDocument.xmlText(); - } - - public static HostDescription fromXML(String xml) throws XmlException { - HostDescription host = new HostDescription(); - host.hostDocument = HostDescriptionDocument.Factory.parse(xml); - return host; - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/airavata/blob/febe2f92/modules/commons/gfac-schema/src/main/java/org/apache/airavata/commons/gfac/type/MappingFactory.java ---------------------------------------------------------------------- diff --git a/modules/commons/gfac-schema/src/main/java/org/apache/airavata/commons/gfac/type/MappingFactory.java b/modules/commons/gfac-schema/src/main/java/org/apache/airavata/commons/gfac/type/MappingFactory.java deleted file mode 100644 index d78e068..0000000 --- a/modules/commons/gfac-schema/src/main/java/org/apache/airavata/commons/gfac/type/MappingFactory.java +++ /dev/null @@ -1,184 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -package org.apache.airavata.commons.gfac.type; - -import java.util.Arrays; -import java.util.List; - -import org.apache.airavata.common.utils.StringUtil; -import org.apache.airavata.schemas.gfac.BooleanArrayType; -import org.apache.airavata.schemas.gfac.BooleanParameterType; -import org.apache.airavata.schemas.gfac.DataType; -import org.apache.airavata.schemas.gfac.DoubleArrayType; -import org.apache.airavata.schemas.gfac.DoubleParameterType; -import org.apache.airavata.schemas.gfac.FileArrayType; -import org.apache.airavata.schemas.gfac.FileParameterType; -import org.apache.airavata.schemas.gfac.FloatArrayType; -import org.apache.airavata.schemas.gfac.FloatParameterType; -import org.apache.airavata.schemas.gfac.IntegerArrayType; -import org.apache.airavata.schemas.gfac.IntegerParameterType; -import org.apache.airavata.schemas.gfac.StdErrParameterType; -import org.apache.airavata.schemas.gfac.StdOutParameterType; -import org.apache.airavata.schemas.gfac.StringArrayType; -import org.apache.airavata.schemas.gfac.StringParameterType; -import org.apache.airavata.schemas.gfac.URIArrayType; -import org.apache.airavata.schemas.gfac.URIParameterType; - -import com.sun.org.apache.xpath.internal.operations.Quo; - -/* - * TODO use XML meta data instead of static coding - * - */ -public class MappingFactory { - - /** - * This method is used to map between ENUM datatype to actual parameter type for example: Enum type String will map - * to StringParameterType in XMLSchema - * - * @param type - * @return - */ - public static String getActualParameterType(DataType.Enum type) { - if (type.equals(DataType.STRING)) { - return StringParameterType.class.getSimpleName(); - } else if (type.equals(DataType.INTEGER)) { - return IntegerParameterType.class.getSimpleName(); - } else if (type.equals(DataType.DOUBLE)) { - return DoubleParameterType.class.getSimpleName(); - } else if (type.equals(DataType.BOOLEAN)) { - return BooleanParameterType.class.getSimpleName(); - } else if (type.equals(DataType.FILE)) { - return FileParameterType.class.getSimpleName(); - } else if (type.equals(DataType.FLOAT)) { - return FloatParameterType.class.getSimpleName(); - } else if (type.equals(DataType.URI)) { - return URIParameterType.class.getSimpleName(); - } else if (type.equals(DataType.STRING_ARRAY)) { - return StringArrayType.class.getSimpleName(); - } else if (type.equals(DataType.INTEGER_ARRAY)) { - return IntegerArrayType.class.getSimpleName(); - } else if (type.equals(DataType.DOUBLE_ARRAY)) { - return DoubleArrayType.class.getSimpleName(); - } else if (type.equals(DataType.BOOLEAN_ARRAY)) { - return BooleanArrayType.class.getSimpleName(); - } else if (type.equals(DataType.FILE_ARRAY)) { - return FileArrayType.class.getSimpleName(); - } else if (type.equals(DataType.FLOAT_ARRAY)) { - return FloatArrayType.class.getSimpleName(); - } else if (type.equals(DataType.URI_ARRAY)) { - return URIArrayType.class.getSimpleName(); - } else if (type.equals(DataType.STD_OUT)){ - return StdOutParameterType.class.getSimpleName(); - } else if (type.equals(DataType.STD_ERR)){ - return StdErrParameterType.class.getSimpleName(); - } - - return StringParameterType.class.getSimpleName(); - } - - /** - * This method is used to map from Actual parameter type to String. It is used for mapping between ParamaterType in - * XML to command-line application arguments - * - * @param param - * @return - */ - public static String toString(ActualParameter param) { - if (param.hasType(DataType.STRING)) { - return ((StringParameterType) param.getType()).getValue(); - } else if (param.hasType(DataType.INTEGER)) { - return String.valueOf(((IntegerParameterType) param.getType()).getValue()); - } else if (param.hasType(DataType.DOUBLE)) { - return String.valueOf(((DoubleParameterType) param.getType()).getValue()); - } else if (param.hasType(DataType.BOOLEAN)) { - return String.valueOf(((BooleanParameterType) param.getType()).getValue()); - } else if (param.hasType(DataType.FILE)) { - return ((FileParameterType) param.getType()).getValue(); - } else if (param.hasType(DataType.FLOAT)) { - return String.valueOf(((FloatParameterType) param.getType()).getValue()); - } else if (param.hasType(DataType.URI)) { - return String.valueOf(((URIParameterType) param.getType()).getValue()); - } else if (param.hasType(DataType.STRING_ARRAY)) { - return join(Arrays.asList(((StringArrayType) param.getType()).getValueArray()), StringUtil.DELIMETER); - } else if (param.hasType(DataType.STD_OUT)) { - return String.valueOf(((StdOutParameterType) param.getType()).getValue()); - } else if (param.hasType(DataType.STD_ERR)) { - return String.valueOf(((StdErrParameterType) param.getType()).getValue()); - } else if (param.hasType(DataType.INTEGER_ARRAY)) { - //todo return proper string array from int,double,boolean arrays - return String.valueOf(((IntegerArrayType) param.getType()).getValueArray()); - } else if (param.hasType(DataType.DOUBLE_ARRAY)) { - return String.valueOf(((DoubleArrayType) param.getType()).getValueArray()); - } else if (param.hasType(DataType.BOOLEAN_ARRAY)) { - return String.valueOf(((BooleanArrayType) param.getType()).getValueArray()); - } else if (param.hasType(DataType.FILE_ARRAY)) { - return join(Arrays.asList(((FileArrayType) param.getType()).getValueArray()), StringUtil.DELIMETER ); - } else if (param.hasType(DataType.FLOAT_ARRAY)) { - return String.valueOf(((FloatArrayType) param.getType()).getValueArray()); - } else if (param.hasType(DataType.URI_ARRAY)) { - return join(Arrays.asList(((URIArrayType) param.getType()).getValueArray()), StringUtil.DELIMETER ); - } - return null; - } - - /** - * This method is used to map output from command-line application to actual parameter in XML Schema. - * - * @param param - * @param val - */ - public static void fromString(ActualParameter param, String val) { - if (param.hasType(DataType.STRING)) { - ((StringParameterType) param.getType()).setValue(val); - } else if (param.hasType(DataType.INTEGER)) { - ((IntegerParameterType) param.getType()).setValue(Integer.parseInt(val)); - } else if (param.hasType(DataType.DOUBLE)) { - ((DoubleParameterType) param.getType()).setValue(Double.parseDouble(val)); - } else if (param.hasType(DataType.BOOLEAN)) { - ((BooleanParameterType) param.getType()).setValue(Boolean.parseBoolean(val)); - } else if (param.hasType(DataType.FILE)) { - ((FileParameterType) param.getType()).setValue(val); - } else if (param.hasType(DataType.FLOAT)) { - ((FloatParameterType) param.getType()).setValue(Float.parseFloat(val)); - } else if (param.hasType(DataType.URI)) { - ((URIParameterType) param.getType()).setValue((val)); - } - } - - public static String join(List<String> list, String delim) { - - StringBuilder sb = new StringBuilder(); - - String loopDelim = ""; - - for (String s : list) { - - sb.append(loopDelim); - sb.append(StringUtil.quoteString(s)); - - loopDelim = delim; - } - - return sb.toString(); - } -} http://git-wip-us.apache.org/repos/asf/airavata/blob/febe2f92/modules/commons/gfac-schema/src/main/java/org/apache/airavata/commons/gfac/type/ServiceDescription.java ---------------------------------------------------------------------- diff --git a/modules/commons/gfac-schema/src/main/java/org/apache/airavata/commons/gfac/type/ServiceDescription.java b/modules/commons/gfac-schema/src/main/java/org/apache/airavata/commons/gfac/type/ServiceDescription.java deleted file mode 100644 index 3494035..0000000 --- a/modules/commons/gfac-schema/src/main/java/org/apache/airavata/commons/gfac/type/ServiceDescription.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -package org.apache.airavata.commons.gfac.type; - -import org.apache.airavata.schemas.gfac.ServiceDescriptionDocument; -import org.apache.airavata.schemas.gfac.ServiceDescriptionType; -import org.apache.xmlbeans.XmlException; - -public class ServiceDescription implements Type { - - private static final long serialVersionUID = -4365350045872875217L; - private ServiceDescriptionDocument serviceDocument; - - public ServiceDescription() { - this.serviceDocument = ServiceDescriptionDocument.Factory.newInstance(); - this.serviceDocument.addNewServiceDescription(); - } - - public ServiceDescriptionType getType() { - return this.serviceDocument.getServiceDescription(); - } - - public String toXML() { - return serviceDocument.xmlText(); - } - - public static ServiceDescription fromXML(String xml) throws XmlException { - ServiceDescription service = new ServiceDescription(); - service.serviceDocument = ServiceDescriptionDocument.Factory.parse(xml); - return service; - } -} http://git-wip-us.apache.org/repos/asf/airavata/blob/febe2f92/modules/commons/gfac-schema/src/main/java/org/apache/airavata/commons/gfac/type/Type.java ---------------------------------------------------------------------- diff --git a/modules/commons/gfac-schema/src/main/java/org/apache/airavata/commons/gfac/type/Type.java b/modules/commons/gfac-schema/src/main/java/org/apache/airavata/commons/gfac/type/Type.java deleted file mode 100644 index 8cb672b..0000000 --- a/modules/commons/gfac-schema/src/main/java/org/apache/airavata/commons/gfac/type/Type.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -package org.apache.airavata.commons.gfac.type; - -import java.io.Serializable; - -public interface Type extends Serializable { -} http://git-wip-us.apache.org/repos/asf/airavata/blob/febe2f92/modules/commons/gfac-schema/src/main/java/org/apache/airavata/commons/gfac/wsdl/GFacSchemaConstants.java ---------------------------------------------------------------------- diff --git a/modules/commons/gfac-schema/src/main/java/org/apache/airavata/commons/gfac/wsdl/GFacSchemaConstants.java b/modules/commons/gfac-schema/src/main/java/org/apache/airavata/commons/gfac/wsdl/GFacSchemaConstants.java deleted file mode 100644 index 8bd63c9..0000000 --- a/modules/commons/gfac-schema/src/main/java/org/apache/airavata/commons/gfac/wsdl/GFacSchemaConstants.java +++ /dev/null @@ -1,119 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -package org.apache.airavata.commons.gfac.wsdl; - -public class GFacSchemaConstants { - - public static final String SHUTDOWN = "Shutdown"; - - public static final String PING = "Ping"; - - public static final String KILL = "Kill"; - - public static final String ARRAY_VALUE = "value"; - - public static final String _127_0_0_1 = "127.0.0.1"; - - public static final String GFAC_NAMESPACE = "http://airavata.apache.org/schemas/gfac/2012/12"; - - public static final String TRANSPORT_LEVEL = "TransportLevel"; - - public static final String MESSAGE_SIGNATURE = "MessageSignature"; - - // Specific to application service - public static final String SERVICE_URI = "SERVICE_URI"; - - public static final String METHOD_NAME = "METHOD_NAME"; - - public static final String SERVICE_NAME = "SERVICE_NAME"; - - public static final String APP_SERVICE_STRING_PARAM = "AFAC_STRING_PARAM"; - - public static final String SERVICE_RESP_MSG_SUFFIX = "_ResponseMessage"; - - public static final String SERVICE_INPUT_PARAMS_TYPE_SUFFIX = "_InputParamsType"; - - public static final String SERVICE_OUTPUT_PARAMS_TYPE_SUFFIX = "_OutputParamsType"; - - public static final String SERVICE_REQ_MSG_SUFFIX = "_RequestMessage"; - - public static final String SERVICE_IN_PARAMS_SUFFIX = "_InputParams"; - - public static final String SERVICE_OUT_PARAMS_SUFFIX = "_OutputParams"; - - public static final String SERVICE_TMP_DIR = "AFAC_TMP_DIR"; - - public static final String SERVICE_INPUT_MESSAGE_NAME = "AFAC_INPUT_MESSAGE_NAME"; - - public static final String HOST = "host"; - - public static final String UTF8 = "UTF-8"; - - public static final String LOCALHOST = "localhost"; - - public static interface InbuitOperations { - public static final String OP_KILL = "Kill"; - - public static final String OP_PING = "Ping"; - - public static final String OP_SHUTDOWN = "Shutdown"; - } - - public static class Types { - public static final String TYPE_STRING = "String"; - - public static final String TYPE_INT = "Integer"; - - public static final String TYPE_FLOAT = "Float"; - - public static final String TYPE_DOUBLE = "Double"; - - public static final String TYPE_BOOLEAN = "Boolean"; - - public static final String TYPE_QNAME = "QName"; - - public static final String TYPE_URI = "URI"; - - public static final String TYPE_STRING_ARRAY = "StringArray"; - - public static final String TYPE_INT_ARRAY = "IntegerArray"; - - public static final String TYPE_FLAOT_ARRAY = "FloatArray"; - - public static final String TYPE_DOUBLE_ARRAY = "DoubleArray"; - - public static final String TYPE_BOOLEAN_ARRAY = "BooleanArray"; - - public static final String TYPE_QNAME_ARRAY = "QNameArray"; - - public static final String TYPE_URI_ARRAY = "URIArray"; - - public static final String TYPE_STDOUT = "StdOut"; - - public static final String TYPE_STDERRORs = "StdErr"; - - public static final String TYPE_DATAID = "DataID"; - - public static final String TYPE_DATAID_ARRAY = "DataIDArray"; - } - -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/airavata/blob/febe2f92/modules/commons/gfac-schema/src/main/java/org/apache/airavata/commons/gfac/wsdl/GFacWSDLException.java ---------------------------------------------------------------------- diff --git a/modules/commons/gfac-schema/src/main/java/org/apache/airavata/commons/gfac/wsdl/GFacWSDLException.java b/modules/commons/gfac-schema/src/main/java/org/apache/airavata/commons/gfac/wsdl/GFacWSDLException.java deleted file mode 100644 index ea33611..0000000 --- a/modules/commons/gfac-schema/src/main/java/org/apache/airavata/commons/gfac/wsdl/GFacWSDLException.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -package org.apache.airavata.commons.gfac.wsdl; - -public class GFacWSDLException extends Exception { - - /** - * serialVersionUID - */ - private static final long serialVersionUID = 3146697337237463348L; - - public GFacWSDLException(String message, Throwable cause) { - super(message, cause); - } - - public GFacWSDLException(String message) { - super(message); - } - - public GFacWSDLException(Throwable cause) { - super(cause); - } - -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/airavata/blob/febe2f92/modules/commons/gfac-schema/src/main/java/org/apache/airavata/commons/gfac/wsdl/RoundTrip.java ---------------------------------------------------------------------- diff --git a/modules/commons/gfac-schema/src/main/java/org/apache/airavata/commons/gfac/wsdl/RoundTrip.java b/modules/commons/gfac-schema/src/main/java/org/apache/airavata/commons/gfac/wsdl/RoundTrip.java deleted file mode 100644 index 51ca8e6..0000000 --- a/modules/commons/gfac-schema/src/main/java/org/apache/airavata/commons/gfac/wsdl/RoundTrip.java +++ /dev/null @@ -1,141 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -package org.apache.airavata.commons.gfac.wsdl; - -import java.io.IOException; -import java.io.Reader; -import java.io.StringReader; -import java.io.StringWriter; -import java.io.Writer; - -import org.xmlpull.v1.XmlPullParser; -import org.xmlpull.v1.XmlPullParserException; -import org.xmlpull.v1.XmlPullParserFactory; -import org.xmlpull.v1.XmlSerializer; - -/** - * This sample demonstrates how to roundtrip XML document (roundtrip is not exact but infoset level) - */ - -public class RoundTrip { - private final static String PROPERTY_XMLDECL_STANDALONE = "http://xmlpull.org/v1/doc/features.html#xmldecl-standalone"; - private final static String PROPERTY_SERIALIZER_INDENTATION = "http://xmlpull.org/v1/doc/properties.html#serializer-indentation"; - private XmlPullParser parser; - private XmlSerializer serializer; - - private RoundTrip(XmlPullParser parser, XmlSerializer serializer) { - this.parser = parser; - this.serializer = serializer; - } - - private void writeStartTag() throws XmlPullParserException, IOException { - // check for case when feature xml roundtrip is supported - // if (parser.getFeature (FEATURE_XML_ROUNDTRIP)) { - if (!parser.getFeature(XmlPullParser.FEATURE_REPORT_NAMESPACE_ATTRIBUTES)) { - for (int i = parser.getNamespaceCount(parser.getDepth() - 1); i <= parser.getNamespaceCount(parser - .getDepth()) - 1; i++) { - serializer.setPrefix(parser.getNamespacePrefix(i), parser.getNamespaceUri(i)); - } - } - serializer.startTag(parser.getNamespace(), parser.getName()); - for (int i = 0; i < parser.getAttributeCount(); i++) { - serializer.attribute(parser.getAttributeNamespace(i), parser.getAttributeName(i), - parser.getAttributeValue(i)); - } - // serializer.closeStartTag(); - } - - private void writeToken(int eventType) throws XmlPullParserException, IOException { - switch (eventType) { - case XmlPullParser.START_DOCUMENT: - // use Boolean.TRUE to make it standalone - Boolean standalone = (Boolean) parser.getProperty(PROPERTY_XMLDECL_STANDALONE); - serializer.startDocument(parser.getInputEncoding(), standalone); - break; - case XmlPullParser.END_DOCUMENT: - serializer.endDocument(); - break; - case XmlPullParser.START_TAG: - writeStartTag(); - break; - case XmlPullParser.END_TAG: - serializer.endTag(parser.getNamespace(), parser.getName()); - break; - case XmlPullParser.IGNORABLE_WHITESPACE: - // comment it to remove ignorable whtespaces from XML infoset - String s = parser.getText(); - serializer.ignorableWhitespace(s); - break; - case XmlPullParser.TEXT: - serializer.text(parser.getText()); - break; - case XmlPullParser.ENTITY_REF: - serializer.entityRef(parser.getName()); - break; - case XmlPullParser.CDSECT: - serializer.cdsect(parser.getText()); - break; - case XmlPullParser.PROCESSING_INSTRUCTION: - serializer.processingInstruction(parser.getText()); - break; - case XmlPullParser.COMMENT: - serializer.comment(parser.getText()); - break; - case XmlPullParser.DOCDECL: - serializer.docdecl(parser.getText()); - break; - } - } - - private void roundTrip() throws XmlPullParserException, IOException { - parser.nextToken(); // read first token - writeToken(XmlPullParser.START_DOCUMENT); // write optional XMLDecl if - // present - while (parser.getEventType() != XmlPullParser.END_DOCUMENT) { - writeToken(parser.getEventType()); - parser.nextToken(); - } - writeToken(XmlPullParser.END_DOCUMENT); - } - - public static void roundTrip(Reader reader, Writer writer, String indent) throws XmlPullParserException, - IOException { - XmlPullParserFactory factory = XmlPullParserFactory.newInstance(); - factory.setNamespaceAware(true); - XmlPullParser pp = factory.newPullParser(); - pp.setInput(reader); - XmlSerializer serializer = factory.newSerializer(); - serializer.setOutput(writer); - if (indent != null) { - serializer.setProperty(PROPERTY_SERIALIZER_INDENTATION, indent); - } - (new RoundTrip(pp, serializer)).roundTrip(); - } - - public static void main(String[] args) throws Exception { - String XML = "<test><foo>fdf</foo></test>"; - Reader r = new StringReader(XML); - Writer w = new StringWriter(); - roundTrip(r, w, " "); - System.out.println("indented XML=" + w); - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/airavata/blob/febe2f92/modules/commons/gfac-schema/src/main/java/org/apache/airavata/commons/gfac/wsdl/TypesGenerator.java ---------------------------------------------------------------------- diff --git a/modules/commons/gfac-schema/src/main/java/org/apache/airavata/commons/gfac/wsdl/TypesGenerator.java b/modules/commons/gfac-schema/src/main/java/org/apache/airavata/commons/gfac/wsdl/TypesGenerator.java deleted file mode 100644 index 82d52b8..0000000 --- a/modules/commons/gfac-schema/src/main/java/org/apache/airavata/commons/gfac/wsdl/TypesGenerator.java +++ /dev/null @@ -1,281 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -package org.apache.airavata.commons.gfac.wsdl; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Vector; - -import javax.wsdl.Definition; -import javax.wsdl.Types; -import javax.xml.namespace.QName; - -import org.apache.airavata.commons.gfac.type.MappingFactory; -import org.apache.airavata.schemas.gfac.InputParameterType; -import org.apache.airavata.schemas.gfac.OutputParameterType; -import org.apache.airavata.schemas.gfac.ServiceDescriptionType; -import org.w3c.dom.DOMImplementation; -import org.w3c.dom.Document; -import org.w3c.dom.Element; - -import com.ibm.wsdl.extensions.schema.SchemaImpl; - -public class TypesGenerator implements WSDLConstants { - private static final String ENDPOINT_REFERENCE_TYPE = "EndpointReferenceType"; - - public static Types addTypes(Definition def, DOMImplementation dImpl, ServiceDescriptionType serviceDesc, - String typens, String globalTypens) { - - Element documentation = null; - - Document doc = dImpl.createDocument(typens, SCHEMA, null); - - Element schema = doc.createElementNS(XSD_NAMESPACE, "schema"); - // Element schema = doc.getDocumentElement(); - schema.setAttribute(TARGET_NAMESPACE, typens); - schema.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns", "http://www.w3.org/2001/XMLSchema"); - // schema.setAttribute(XMLNS, - // XSD_NAMESPACE); - schema.setAttribute(ELEMENT_FORM_DEFAULT, UNQUALIFIED); - - Element globalSchema = doc.createElementNS(XSD_NAMESPACE, "schema"); - // Element globalSchema = doc.getDocumentElement(); - globalSchema.setAttribute(TARGET_NAMESPACE, globalTypens); - globalSchema.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns", "http://www.w3.org/2001/XMLSchema"); - // globalSchema.setAttribute(XMLNS, - // XSD_NAMESPACE); - globalSchema.setAttribute(ELEMENT_FORM_DEFAULT, UNQUALIFIED); - - Types types = def.createTypes(); - - InputParameterType[] inputParams = serviceDesc.getInputParametersArray(); - Vector inParamNames = new Vector(); - Vector inParamDesc = new Vector(); - Vector inParamTypes = new Vector(); - - for (int k = 0; k < inputParams.length; ++k) { - inParamNames.add(inputParams[k].getParameterName()); - inParamDesc.add(inputParams[k].getParameterDescription()); - // XMLBEANS specific way to get type - inParamTypes.add(MappingFactory.getActualParameterType(inputParams[k].getParameterType().getType())); - inputParams[k].getParameterValueArray(); - } - - OutputParameterType[] outputParams = serviceDesc.getOutputParametersArray(); - Vector outParamNames = new Vector(); - Vector outParamDesc = new Vector(); - Vector outParamTypes = new Vector(); - - for (int k = 0; k < outputParams.length; ++k) { - outParamNames.add(outputParams[k].getParameterName()); - outParamDesc.add(outputParams[k].getParameterDescription()); - // XMLBEANS specific way to get type - outParamTypes.add(MappingFactory.getActualParameterType(outputParams[k].getParameterType().getType())); - } - - String methodName = serviceDesc.getPortType().getMethod().getMethodName(); - WSDLMessageBean wsdlMsgBean = new WSDLMessageBean(); - wsdlMsgBean.setNamespace(typens); - // Set the method name in the message object - wsdlMsgBean.setMethodName(methodName); - - // === write all the input parameters ======== - // Input message name - String inputMessageName = methodName + GFacSchemaConstants.SERVICE_IN_PARAMS_SUFFIX; - - // Set the input message name in the message object - wsdlMsgBean.setInElementName(inputMessageName); - - // local data types - Element wsdlInputParams = doc.createElement("element"); - String inputElementName = methodName + GFacSchemaConstants.SERVICE_IN_PARAMS_SUFFIX; - String inputParametersType = methodName + GFacSchemaConstants.SERVICE_INPUT_PARAMS_TYPE_SUFFIX; - - wsdlInputParams.setAttribute("name", inputElementName); - wsdlInputParams.setAttribute("type", TYPENS + ":" + inputParametersType); - - schema.appendChild(wsdlInputParams); - // local data types - - wsdlMsgBean.setInMsgParamNames(inParamNames); - wsdlMsgBean.setInMsgParamTypes(inParamTypes); - - Element first = doc.createElement(COMPLEX_TYPE); - first.setAttribute("name", inputParametersType); - - Element sequence = doc.createElement("sequence"); - - for (int j = 0; j < inParamNames.size(); ++j) { - Element elem = doc.createElement("element"); - String paramName = (String) inParamNames.get(j); - paramName = paramName.replaceAll(HYPHEN, HYPHEN_REPLACEMENT); - elem.setAttribute("name", paramName); - String dataType = (String) inParamTypes.get(j); - elem.setAttribute("type", "gfac:" + dataType); - - Element annotation = doc.createElement(ANNOTATION); - - // TODO create Metadata - - WSDLGenerator.createMetadata(inputParams[j], doc, annotation); - - documentation = doc.createElement(DOCUMENTATION); - documentation.appendChild(doc.createTextNode((String) inParamDesc.get(j))); - annotation.appendChild(documentation); - elem.appendChild(annotation); - sequence.appendChild(elem); - } // end for inParams - - first.appendChild(sequence); - schema.appendChild(first); - - // write the enumeration types - for (int j = 0; j < inParamNames.size(); ++j) { - String dataType = (String) inParamTypes.get(j); - if (dataType.equals("StringEnum") || dataType.equals("IntegerEnum") || dataType.equals("FloatEnum") - || dataType.equals("DoubleEnum")) { - String paramName = (String) inParamNames.get(j); - String[] paramValues = serviceDesc.getInputParametersArray(j).getParameterValueArray(); - if (paramValues == null) - continue; - Element elem = doc.createElement(SIMPLE_TYPE); - elem.setAttribute("name", methodName + "_" + paramName + "_" + dataType + "Type"); - - for (int k = 0; k < paramValues.length; ++k) { - documentation = doc.createElement(DOCUMENTATION); - // documentation.setAttribute(XML_LANG, - // ENGLISH); - - Element value = doc.createElement("value"); - value.appendChild(doc.createTextNode(paramValues[k])); - documentation.appendChild(value); - elem.appendChild(documentation); - } - - Element restriction = doc.createElement("restriction"); - if (dataType.equals("StringEnum")) { - restriction.setAttribute("base", "xsd:string"); - } else if (dataType.equals("IntegerEnum")) { - restriction.setAttribute("base", "xsd:int"); - } else if (dataType.equals("FloatEnum")) { - restriction.setAttribute("base", "xsd:float"); - } else if (dataType.equals("DoubleEnum")) { - restriction.setAttribute("base", "xsd:double"); - } - for (int k = 0; k < paramValues.length; ++k) { - Element enumeration = doc.createElement("enumeration"); - enumeration.setAttribute("value", paramValues[k]); - restriction.appendChild(enumeration); - } - elem.appendChild(restriction); - schema.appendChild(elem); - } - } - - // ====== write the output parameters ============== - // Output message name - if (outputParams.length > 0) { - String outputMessageName = methodName + GFacSchemaConstants.SERVICE_OUT_PARAMS_SUFFIX; - // Set the output message name in the message object - wsdlMsgBean.setOutElementName(outputMessageName); - Element wsdlOutputParams = doc.createElement("element"); - String outputElementName = methodName + GFacSchemaConstants.SERVICE_OUT_PARAMS_SUFFIX; - String outputParametersType = methodName + GFacSchemaConstants.SERVICE_OUTPUT_PARAMS_TYPE_SUFFIX; - wsdlOutputParams.setAttribute("name", outputElementName); - wsdlOutputParams.setAttribute("type", TYPENS + ":" + outputParametersType); - schema.appendChild(wsdlOutputParams); - wsdlMsgBean.setOutMsgParamNames(outParamNames); - wsdlMsgBean.setOutMsgParamTypes(outParamTypes); - - // Now add the output parameters - first = doc.createElement(COMPLEX_TYPE); - first.setAttribute("name", outputParametersType); - sequence = doc.createElement("sequence"); - - for (int j = 0; j < outParamNames.size(); ++j) { - Element elem = doc.createElement("element"); - elem.setAttribute("name", (String) outParamNames.get(j)); - String dataType = (String) outParamTypes.get(j); - - elem.setAttribute("type", "gfac:" + dataType); - - // Create an annotation - Element annotation = doc.createElement(ANNOTATION); - WSDLGenerator.createMetadata(serviceDesc.getOutputParametersArray(j), doc, annotation); - documentation = doc.createElement(DOCUMENTATION); - documentation.appendChild(doc.createTextNode((String) outParamDesc.get(j))); - annotation.appendChild(documentation); - elem.appendChild(annotation); - sequence.appendChild(elem); - - } // end for outParamNames.size() - } - - first.appendChild(sequence); - schema.appendChild(first); - - // types.setDocumentationElement(schema); - SchemaImpl schemaImpl = new SchemaImpl(); - - Element importEle = doc.createElement("import"); - importEle.setAttribute("namespace", "http://airavata.apache.org/schemas/gfac/2012/12"); - importEle.setAttribute("schemaLocation", "http://airavata.apache.org/schemas/gfac/2012/12/GFacParameterTypes.xsd"); - schema.insertBefore(importEle, schema.getFirstChild()); - - // schema.appendChild(); - - schemaImpl.setElement(schema); - schemaImpl.setElementType(new QName("http://www.w3.org/2001/XMLSchema", "schema")); - - SchemaImpl globalSchemaImpl = new SchemaImpl(); - globalSchemaImpl.setElement(globalSchema); - globalSchemaImpl.setElementType(new QName("http://www.w3.org/2001/XMLSchema", "schema")); - globalSchemaImpl.getElement().setAttribute("xmlns:xsd", "http://www.w3.org/2001/XMLSchema"); - - types.addExtensibilityElement(schemaImpl); - - return types; - } - - public static Element createAddressingSchema(Document doc) { - Element wsAddressing = doc.createElementNS(XSD_NAMESPACE, "schema"); - // Element globalSchema = doc.getDocumentElement(); - wsAddressing.setAttribute(TARGET_NAMESPACE, "http://www.w3.org/2005/08/addressing"); - wsAddressing.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns", "http://www.w3.org/2001/XMLSchema"); - wsAddressing.setAttribute("attributeFormDefault", "unqualified"); - wsAddressing.setAttribute(ELEMENT_FORM_DEFAULT, "qualified"); - - Element type = doc.createElement("complexType"); - type.setAttribute("name", ENDPOINT_REFERENCE_TYPE); - - Element sequence = doc.createElement("sequence"); - Element any = doc.createElement("any"); - any.setAttribute("namespace", "##any"); - any.setAttribute("minOccurs", "0"); - - sequence.appendChild(any); - type.appendChild(sequence); - wsAddressing.appendChild(type); - - return wsAddressing; - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/airavata/blob/febe2f92/modules/commons/gfac-schema/src/main/java/org/apache/airavata/commons/gfac/wsdl/WSDLConstants.java ---------------------------------------------------------------------- diff --git a/modules/commons/gfac-schema/src/main/java/org/apache/airavata/commons/gfac/wsdl/WSDLConstants.java b/modules/commons/gfac-schema/src/main/java/org/apache/airavata/commons/gfac/wsdl/WSDLConstants.java deleted file mode 100644 index 7e04d05..0000000 --- a/modules/commons/gfac-schema/src/main/java/org/apache/airavata/commons/gfac/wsdl/WSDLConstants.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -package org.apache.airavata.commons.gfac.wsdl; - -public interface WSDLConstants { - // For wsdl generation - public final static String TYPENS = "typens"; - - public final static String GLOBAL_TYPENS = "globalTypens"; - - public final static String WSDLNS = "wsdlns"; - - public final static String SOAP = "soap"; - - public final static String XSD = "xsd"; - - public final static String XMLNS = "xmlns"; - - public final static String TARGET_NAMESPACE = "targetNamespace"; - - public static final String TRANSPORT_LEVEL = "TransportLevel"; - - public final static String SCHEMA = "schema"; - - public final static String ELEMENT_FORM_DEFAULT = "elementFormDefault"; - - public final static String UNQUALIFIED = "unqualified"; - - public final static String ANNOTATION = "annotation"; - - public final static String WSDL_DOCUMENTATION = "wsdl:documentation"; - - public final static String DOCUMENTATION = "documentation"; - - public static final String SERVICE_QNAME = "SERVICE_QNAME"; - - public final static String AWSDL = "AWSDL"; - - public static final String WSDL_PORT_SUFFIX = "_Port"; - - public static final String WSDL_SOAP_BINDING_SUFFIX = "_SoapBinding"; - - public static final String LITERAL = "literal"; - - public static final String DOCUMENT = "document"; - - public static final String XSD_STRING_TYPE = "xsd:string"; - - public static final String COMPLEX_TYPE = "complexType"; - - public static final String SIMPLE_TYPE = "simpleType"; - - public static final String PART_NAME = "parameters"; - - public final static String WSDL = "WSDL"; - - public final static String WSDL_QNAME = "WSDL_QNAME"; - - public static final String XSD_NAMESPACE = "http://www.w3.org/2001/XMLSchema"; - - public static final String WSDL_NAMEPSPACE = "http://schemas.xmlsoap.org/wsdl/"; - - public static final String SOAP_NAMESPACE = "http://schemas.xmlsoap.org/wsdl/soap/"; - - public static final String SOAP_HTTP_NAMESPACE = "http://schemas.xmlsoap.org/soap/http"; - - public static final String WSP_NAMESPACE = "http://schemas.xmlsoap.org/ws/2004/09/policy"; - - public static final String WSPE_NAMESPACE = "http://schemas.xmlsoap.org/ws/2004/09/policy/encoding"; - - public static final String WSA_NAMESPACE = "http://schemas.xmlsoap.org/ws/2004/08/addressing"; - - public static final String WSU_NAMESPACE = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"; - - public static final String SP_NAMESPACE = "http://schemas.xmlsoap.org/ws/2005/07/securitypolicy"; - - public static final String WSS10_NAMESPACE = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"; - - public static final String WST_NAMESPACE = "http://schemas.xmlsoap.org/ws/2005/02/trust"; - - public static final String SERVICE_LOCATION = "ServiceLocation"; - - public static final String HYPHEN_REPLACEMENT = "GFAC_MINUS_REPLACEMENT"; - - public static final String HYPHEN = "-"; - -} http://git-wip-us.apache.org/repos/asf/airavata/blob/febe2f92/modules/commons/gfac-schema/src/main/java/org/apache/airavata/commons/gfac/wsdl/WSDLGenerator.java ---------------------------------------------------------------------- diff --git a/modules/commons/gfac-schema/src/main/java/org/apache/airavata/commons/gfac/wsdl/WSDLGenerator.java b/modules/commons/gfac-schema/src/main/java/org/apache/airavata/commons/gfac/wsdl/WSDLGenerator.java deleted file mode 100644 index ecbc7e7..0000000 --- a/modules/commons/gfac-schema/src/main/java/org/apache/airavata/commons/gfac/wsdl/WSDLGenerator.java +++ /dev/null @@ -1,583 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -package org.apache.airavata.commons.gfac.wsdl; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.Reader; -import java.io.StringReader; -import java.io.StringWriter; -import java.io.Writer; -import java.util.Date; -import java.util.Hashtable; -import java.util.Random; -import java.util.UUID; - -import javax.wsdl.Binding; -import javax.wsdl.BindingOperation; -import javax.wsdl.Definition; -import javax.wsdl.OperationType; -import javax.wsdl.Types; -import javax.wsdl.WSDLException; -import javax.wsdl.extensions.UnknownExtensibilityElement; -import javax.wsdl.extensions.soap.SOAPOperation; -import javax.wsdl.factory.WSDLFactory; -import javax.wsdl.xml.WSDLWriter; -import javax.xml.namespace.QName; - -import org.apache.airavata.schemas.gfac.InputParameterType; -import org.apache.airavata.schemas.gfac.MethodType; -import org.apache.airavata.schemas.gfac.OutputParameterType; -import org.apache.airavata.schemas.gfac.PortTypeType; -import org.apache.airavata.schemas.gfac.ServiceDescriptionType; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.w3c.dom.Attr; -import org.w3c.dom.Comment; -import org.w3c.dom.DOMImplementation; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; -import org.w3c.dom.Text; -import org.xmlpull.v1.XmlPullParserException; - -import com.ibm.wsdl.BindingInputImpl; -import com.ibm.wsdl.BindingOutputImpl; -import com.ibm.wsdl.InputImpl; -import com.ibm.wsdl.MessageImpl; -import com.ibm.wsdl.OperationImpl; -import com.ibm.wsdl.OutputImpl; -import com.ibm.wsdl.PartImpl; -import com.ibm.wsdl.PortImpl; -import com.ibm.wsdl.PortTypeImpl; -import com.ibm.wsdl.ServiceImpl; -import com.ibm.wsdl.extensions.soap.SOAPAddressImpl; -import com.ibm.wsdl.extensions.soap.SOAPBindingImpl; -import com.ibm.wsdl.extensions.soap.SOAPBodyImpl; -import com.ibm.wsdl.extensions.soap.SOAPOperationImpl; - -public class WSDLGenerator implements WSDLConstants { - public static final String WSA_PREFIX = "wsa"; - protected final Logger log = LoggerFactory.getLogger(this.getClass()); - - public Hashtable generateWSDL(String serviceLocation, QName wsdlQName_, String security, - ServiceDescriptionType serviceDesc, boolean abstractWSDL) throws GFacWSDLException { - Hashtable table = new Hashtable(); - QName wsdlQName = null; - String wsdlString = null; - String serviceName = serviceDesc.getService().getServiceName().getStringValue(); - String nameSpaceURI = serviceDesc.getService().getServiceName().getTargetNamespace(); - QName serviceQName = new QName(nameSpaceURI, serviceName); - - if (wsdlQName_ != null && !abstractWSDL) { - wsdlQName = wsdlQName_; - } else if (wsdlQName_ == null && !abstractWSDL) { - String date = (new Date()).toString(); - date = date.replaceAll(" ", "_"); - date = date.replaceAll(":", "_"); - Random rand = new Random(); - int rdint = rand.nextInt(1000000); - wsdlQName = new QName(nameSpaceURI, serviceName + "_" + date + "_" + rdint); - } - - PortTypeType portType = serviceDesc.getPortType(); - MethodType method = portType.getMethod(); - QName portTypeName = serviceQName; - - String portName = portTypeName.getLocalPart(); - - try { - WSDLFactory fac = WSDLFactory.newInstance(); - WSDLWriter wsWriter = fac.newWSDLWriter(); - - // =========== start of wsdl definition =========== - Definition def = fac.newDefinition(); - - String typens = nameSpaceURI + "/" + portName + "/" + "xsd"; - String globalTypens = nameSpaceURI + "/" + "xsd"; - - if (abstractWSDL) { - def.setQName(serviceQName); - log.debug("Service QName set to = " + serviceQName); - } else { - def.setQName(wsdlQName); - log.debug("WSDL QName set to = " + wsdlQName); - } - - // namespaces =========== - def.setTargetNamespace(nameSpaceURI); - def.addNamespace(WSDLNS, nameSpaceURI); - def.addNamespace(TYPENS, typens); - def.addNamespace(GLOBAL_TYPENS, globalTypens); - def.addNamespace(SOAP, SOAP_NAMESPACE); - def.addNamespace(XSD, XSD_NAMESPACE); - def.addNamespace(WSA_PREFIX, "http://www.w3.org/2005/08/addressing"); - def.addNamespace("gfac", "http://airavata.apache.org/schemas/gfac/2012/12"); - - - if (GFacSchemaConstants.TRANSPORT_LEVEL.equals(security) - || GFacSchemaConstants.MESSAGE_SIGNATURE.equals(security)) { - def.addNamespace(WSA_PREFIX, WSA_NAMESPACE); - def.addNamespace("wsp", WSP_NAMESPACE); - def.addNamespace("wsu", WSU_NAMESPACE); - def.addNamespace("wspe", WSPE_NAMESPACE); - def.addNamespace("sp", SP_NAMESPACE); - def.addNamespace("wss10", WSS10_NAMESPACE); - - def.addNamespace("sp", SP_NAMESPACE); - def.addNamespace("wst", WST_NAMESPACE); - } - // =========== end of wsdl namespaces =========== - - javax.xml.parsers.DocumentBuilderFactory domfactory = javax.xml.parsers.DocumentBuilderFactory - .newInstance(); - javax.xml.parsers.DocumentBuilder builder = null; - - try { - builder = domfactory.newDocumentBuilder(); - } catch (javax.xml.parsers.ParserConfigurationException e) { - throw new GFacWSDLException("Parser configuration exception: " + e.getMessage()); - } - - DOMImplementation dImpl = builder.getDOMImplementation(); - - String policyID = portName + "_Policy"; - String inputPolicyID = portName + "_operationPolicy"; - - UnknownExtensibilityElement serviceLevelPolicRef = null; - UnknownExtensibilityElement opLevelPolicRef = null; - - String namespace = GFacSchemaConstants.GFAC_NAMESPACE; - Document doc = dImpl.createDocument(namespace, "factoryServices", null); - - String description = serviceDesc.getService().getServiceDescription(); - if (description != null) { - Element documentation = doc.createElementNS("http://schemas.xmlsoap.org/wsdl/", "wsdl:documentation"); - documentation.appendChild(doc.createTextNode(description)); - def.setDocumentationElement(documentation); - } - - if (GFacSchemaConstants.TRANSPORT_LEVEL.equals(security)) { - def.addExtensibilityElement(createTransportLevelPolicy(dImpl, policyID)); - serviceLevelPolicRef = createWSPolicyRef(dImpl, policyID); - } else if (GFacSchemaConstants.MESSAGE_SIGNATURE.equals(security)) { - def.addExtensibilityElement(WSPolicyGenerator.createServiceLevelPolicy(dImpl, policyID)); - serviceLevelPolicRef = createWSPolicyRef(dImpl, policyID); - opLevelPolicRef = createWSPolicyRef(dImpl, inputPolicyID); - } - - // Create types - Types types = TypesGenerator.addTypes(def, dImpl, serviceDesc, typens, globalTypens); - def.setTypes(types); - - // if(!abstractWSDL) - // { - // table = createMessageTable(serviceDesc, typens, operation); - // } - - // Create port types (only first port type) - PortTypeImpl wsdlPortType = addPortTypes(def, dImpl, portType, serviceQName); - Binding binding = addBinding(def, nameSpaceURI, wsdlPortType, serviceLevelPolicRef, dImpl); - - String methodDesc = serviceDesc.getPortType().getMethod().getMethodDescription(); - String methodName = serviceDesc.getPortType().getMethod().getMethodName(); - OutputParameterType[] outputParams = serviceDesc.getOutputParametersArray(); - - OperationImpl operation = addOperation(def, dImpl, methodName, methodDesc, typens, outputParams); - wsdlPortType.addOperation(operation); - - if (!abstractWSDL) { - UnknownExtensibilityElement wsInPolicyRef = null; - UnknownExtensibilityElement wsOutPolicyRef = null; - - BindingInputImpl bindingInput = addBindingInput(def, methodName, wsInPolicyRef); - BindingOutputImpl bindingOutput = addBindingOutput(def, methodName, outputParams, wsOutPolicyRef); - BindingOperation bindingOperation = addBindingOperation(def, operation, dImpl); - bindingOperation.setBindingInput(bindingInput); - bindingOperation.setBindingOutput(bindingOutput); - binding.addBindingOperation(bindingOperation); - - if (opLevelPolicRef != null) { - binding.addExtensibilityElement(opLevelPolicRef); - } - - } - def.addPortType(wsdlPortType); - - // =========== end of wsdl binding =========== - - // FIXME: This is done as factory information is not needed - // if(abstractWSDL) - // { - // - // - // Element factoryServices = doc.createElement("n:factoryServices"); - // factoryServices.setAttribute("xmlns:n", namespace); - // Element factoryService = doc.createElement("n:factoryService"); - // factoryService.setAttribute("location", - // "http://rainier.extreme.indiana.edu:12345"); - // factoryService.setAttribute("portType", "n:GenericFactory"); - // factoryService.setAttribute("operation", "n:CreateService"); - // factoryServices.appendChild(factoryService); - // UnknownExtensibilityElement elem = new - // UnknownExtensibilityElement(); - // elem.setElement(factoryServices); - // def.addExtensibilityElement(elem); - // } - - if (!abstractWSDL) { - def.addBinding(binding); - ServiceImpl service = (ServiceImpl) def.createService(); - service.setQName(wsdlQName); - - PortImpl port = (PortImpl) def.createPort(); - port.setName(wsdlQName.getLocalPart() + WSDL_PORT_SUFFIX); - port.setBinding(binding); - service.addPort(port); - - SOAPAddressImpl soapAddress = new SOAPAddressImpl(); - soapAddress.setLocationURI(serviceLocation); - port.addExtensibilityElement(soapAddress); - def.addService(service); - } - - if (!abstractWSDL) { - table.put(WSDL_QNAME, wsdlQName); - } - - table.put(SERVICE_QNAME, serviceQName); - - ByteArrayOutputStream bs = new ByteArrayOutputStream(); - wsWriter.writeWSDL(def, bs); - wsdlString = bs.toString(); - } catch (WSDLException e) { - throw new GFacWSDLException("Error generating WSDL: " + e.getMessage()); - } - - Reader reader = new StringReader(wsdlString); - Writer writer = new StringWriter(); - try { - RoundTrip.roundTrip(reader, writer, " "); - } catch (XmlPullParserException e) { - throw new GFacWSDLException(e); - } catch (IOException e) { - throw new GFacWSDLException(e); - } - wsdlString = writer.toString(); - - if (abstractWSDL) { - table.put(AWSDL, wsdlString); - } else { - table.put(WSDL, wsdlString); - } - return table; - } - - private UnknownExtensibilityElement createWSPolicyRef(DOMImplementation dImpl, String id) { - Document doc = dImpl.createDocument(WSP_NAMESPACE, "wsp:PolicyReference", null); - Element policyRef = doc.getDocumentElement(); - policyRef.setAttribute("URI", "#" + id); - UnknownExtensibilityElement elem = new UnknownExtensibilityElement(); - elem.setElement(policyRef); - elem.setElementType(new QName(WSP_NAMESPACE, "PolicyReference")); - return elem; - } - - private UnknownExtensibilityElement createTransportLevelPolicy(DOMImplementation dImpl, String policyID) { - Document doc = dImpl.createDocument(WSP_NAMESPACE, "wsp:Policy", null); - - Element policy = doc.getDocumentElement(); - policy.setAttribute("wsu:Id", policyID); - Element exactlyOne = doc.createElement("wsp:ExactlyOne"); - Element all = doc.createElement("wsp:All"); - - Element transportBinding = doc.createElement("sp:TransportBinding"); - transportBinding.setAttribute("xmlns:sp", SP_NAMESPACE); - Element policy1 = doc.createElement("wsp:Policy"); - - Element transportToken = doc.createElement("sp:TransportToken"); - Element policy2 = doc.createElement("wsp:Policy"); - Element httpsToken = doc.createElement("sp:HttpsToken"); - httpsToken.setAttribute("RequireClientCertificate", "true"); - policy2.appendChild(httpsToken); - transportToken.appendChild(policy2); - policy1.appendChild(transportToken); - - /* - * Element algorithmSuite = doc.createElement("sp:AlgorithmSuite"); Element policy3 = - * doc.createElement("wsp:Policy"); Element base256 = doc.createElement("sp:Base256"); - * policy3.appendChild(base256); algorithmSuite.appendChild(policy3); policy1.appendChild(algorithmSuite); - * - * - * Element layout = doc.createElement("sp:Layout"); Element policy4 = doc.createElement("wsp:Policy"); Element - * lax = doc.createElement("sp:Lax"); policy4.appendChild(lax); layout.appendChild(policy4); - * policy1.appendChild(layout); - * - * Element includeTimestamp = doc.createElement("sp:includeTimestamp"); policy1.appendChild(includeTimestamp); - */ - - /* - * Element signedSupportingTokens = doc.createElement("sp:SignedSupportingTokens"); policy2 = - * doc.createElement("wsp:Policy"); Element usernameToken = doc.createElement("sp:UsernameToken"); - * usernameToken.setAttribute("sp:IncludeToken", - * "http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/AlwaysToRecipient" ); - * policy2.appendChild(usernameToken); signedSupportingTokens.appendChild(policy2); - * policy1.appendChild(signedSupportingTokens); - */ - - Element signedEndorsingSupportingTokens = doc.createElement("sp:SignedEndorsingSupportingTokens"); - policy2 = doc.createElement("wsp:Policy"); - Element x509V3Token = doc.createElement("sp:X509V3Token"); - // x509V3Token.setAttribute("sp:IncludeToken", - // "http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/Once"); - policy2.appendChild(x509V3Token); - signedEndorsingSupportingTokens.appendChild(policy2); - policy1.appendChild(signedEndorsingSupportingTokens); - - transportBinding.appendChild(policy1); - all.appendChild(transportBinding); - - /* - * Element wss10 = doc.createElement("sp:wss10"); Element requireSignatureConfirmation = - * doc.createElement("sp:RequireSignatureConfirmation"); wss10.appendChild(requireSignatureConfirmation); - * all.appendChild(wss10); - */ - - exactlyOne.appendChild(all); - policy.appendChild(exactlyOne); - - UnknownExtensibilityElement elem = new UnknownExtensibilityElement(); - elem.setElement(policy); - elem.setElementType(new QName(WSP_NAMESPACE, "wsp:Policy")); - return elem; - } - - private PortTypeImpl addPortTypes(Definition def, DOMImplementation dImpl, PortTypeType portType, QName serviceQName) { - // create port type - PortTypeImpl wsdlPortType = (PortTypeImpl) def.createPortType(); - wsdlPortType.setQName(serviceQName); - wsdlPortType.setUndefined(false); - - // create documentation for this port type - Document doc = dImpl.createDocument(WSDL_NAMEPSPACE, WSDL_DOCUMENTATION, null); - Element documentation = doc.getDocumentElement(); - documentation.appendChild(doc.createTextNode(portType.getPortDescription())); - wsdlPortType.setDocumentationElement(documentation); - return wsdlPortType; - } - - private OperationImpl addOperation(Definition def, DOMImplementation dImpl, String methodName, String methodDesc, - String typens, OutputParameterType[] outputParameterTypes) { - OperationImpl operation = (OperationImpl) def.createOperation(); - operation.setUndefined(false); - operation.setName(methodName); - if (outputParameterTypes.length == 0) { - operation.setStyle(OperationType.ONE_WAY); - } else { - operation.setStyle(OperationType.REQUEST_RESPONSE); - } - - Document doc = dImpl.createDocument(WSDL_NAMEPSPACE, WSDL_DOCUMENTATION, null); - Element documentation = doc.createElement(WSDL_DOCUMENTATION); - documentation.appendChild(doc.createTextNode(methodDesc)); - operation.setDocumentationElement(documentation); - - MessageImpl inputMessage = (MessageImpl) def.createMessage(); - String inputMessageName = methodName + GFacSchemaConstants.SERVICE_REQ_MSG_SUFFIX + "_" + UUID.randomUUID(); - - inputMessage.setQName(new QName(def.getTargetNamespace(), inputMessageName)); - inputMessage.setUndefined(false); - - PartImpl inPart = (PartImpl) def.createPart(); - inPart.setName(PART_NAME); - String inputElementName = methodName + GFacSchemaConstants.SERVICE_IN_PARAMS_SUFFIX; - inPart.setElementName(new QName(typens, inputElementName)); - inputMessage.addPart(inPart); - - def.addMessage(inputMessage); - InputImpl ip = (InputImpl) def.createInput(); - ip.setName(inputMessageName); - ip.setMessage(inputMessage); - - operation.setInput(ip); - - if (outputParameterTypes.length > 0) { - MessageImpl outputMessage = (MessageImpl) def.createMessage(); - String outputMessageName = methodName + GFacSchemaConstants.SERVICE_RESP_MSG_SUFFIX + "_" - + UUID.randomUUID(); - outputMessage.setQName(new QName(def.getTargetNamespace(), outputMessageName)); - outputMessage.setUndefined(false); - - PartImpl part = (PartImpl) def.createPart(); - part.setName(PART_NAME); - String outputElementName = methodName + GFacSchemaConstants.SERVICE_OUT_PARAMS_SUFFIX; - - part.setElementName(new QName(typens, outputElementName)); - outputMessage.addPart(part); - def.addMessage(outputMessage); - - OutputImpl op = (OutputImpl) def.createOutput(); - op.setName(outputMessageName); - op.setMessage(outputMessage); - operation.setOutput(op); - } - return operation; - } - - private BindingInputImpl addBindingInput(Definition def, String methodName, UnknownExtensibilityElement wsPolicyRef) { - - BindingInputImpl bindingInput = (BindingInputImpl) def.createBindingInput(); - bindingInput.setName(methodName + GFacSchemaConstants.SERVICE_REQ_MSG_SUFFIX); - if (wsPolicyRef != null) { - log.debug("policy info is not null"); - bindingInput.addExtensibilityElement(wsPolicyRef); - } - SOAPBodyImpl inputExtension = new SOAPBodyImpl(); - inputExtension.setUse(LITERAL); - bindingInput.addExtensibilityElement(inputExtension); - return bindingInput; - } - - private BindingOutputImpl addBindingOutput(Definition def, String methodName, OutputParameterType[] outputParams, - UnknownExtensibilityElement wsPolicyRef) { - // specify output only if there are output parameters - BindingOutputImpl bindingOutput = null; - if (outputParams.length > 0) { - bindingOutput = (BindingOutputImpl) def.createBindingOutput(); - bindingOutput.setName(methodName + GFacSchemaConstants.SERVICE_RESP_MSG_SUFFIX); - if (wsPolicyRef != null) { - log.debug("policy info is not null"); - bindingOutput.addExtensibilityElement(wsPolicyRef); - } - SOAPBodyImpl outputExtension = new SOAPBodyImpl(); - outputExtension.setUse(LITERAL); - bindingOutput.addExtensibilityElement(outputExtension); - } - return bindingOutput; - } - - private BindingOperation addBindingOperation(Definition def, OperationImpl operation, DOMImplementation dImpl) { - BindingOperation bindingOperation = def.createBindingOperation(); - bindingOperation.setName(operation.getName()); - SOAPOperation soapOperation = new SOAPOperationImpl(); - bindingOperation.addExtensibilityElement(soapOperation); - bindingOperation.setOperation(operation); - - Document doc = dImpl.createDocument(WSP_NAMESPACE, "Misc", null); - - UnknownExtensibilityElement exEle = new UnknownExtensibilityElement(); - Element anonymousEle = doc.createElementNS("http://www.w3.org/2006/05/addressing/wsdl", "wsaw:Anonymous"); - anonymousEle.appendChild(doc.createTextNode("optional")); - exEle.setElement(anonymousEle); - exEle.setElementType(new QName("http://www.w3.org/2006/05/addressing/wsdl", "wsaw:Anonymous")); - bindingOperation.addExtensibilityElement(exEle); - return bindingOperation; - } - - private Binding addBinding(Definition def, String nameSpaceURI, PortTypeImpl portType, - UnknownExtensibilityElement wsPolicyRef, DOMImplementation dImpl) { - String portName = portType.getQName().getLocalPart(); - - Binding binding = def.createBinding(); - binding.setQName(new QName(nameSpaceURI, portName + WSDL_SOAP_BINDING_SUFFIX)); - binding.setUndefined(false); - binding.setPortType(portType); - - SOAPBindingImpl soapBindingImpl = new SOAPBindingImpl(); - soapBindingImpl.setStyle(DOCUMENT); - soapBindingImpl.setTransportURI(SOAP_HTTP_NAMESPACE); - binding.addExtensibilityElement(soapBindingImpl); - if (wsPolicyRef != null) { - log.debug("policy info is not null"); - binding.addExtensibilityElement(wsPolicyRef); - } - - Document doc = dImpl.createDocument(WSP_NAMESPACE, "Misc", null); - - UnknownExtensibilityElement exEle = new UnknownExtensibilityElement(); - exEle.setElement(doc.createElementNS("http://www.w3.org/2006/05/addressing/wsdl", "wsaw:UsingAddressing")); - exEle.setElementType(new QName("http://www.w3.org/2006/05/addressing/wsdl", "wsaw:UsingAddressing")); - binding.addExtensibilityElement(exEle); - - return binding; - } - - public static void createMetadata(InputParameterType inparam, Document doc, Element annotation) { - if (inparam.getAnyMetadata() != null) { - unwrapMetadata(doc, annotation, (Element) inparam.getAnyMetadata()); - } - } - - public static void createMetadata(OutputParameterType outparam, Document doc, Element annotation) { - if (outparam.getAnyMetadata() != null) { - // GfacUtils.writeDOM((Element)outparam.getMetadata()); - unwrapMetadata(doc, annotation, (Element) outparam.getAnyMetadata()); - } - } - - private static void unwrapMetadata(Document doc, Element annotation, Element base) { - Element appInfo = doc.createElementNS(XSD_NAMESPACE, "appinfo"); - annotation.appendChild(appInfo); - - NodeList childs = base.getChildNodes(); - for (int i = 0; i < childs.getLength(); i++) { - if (childs.item(i) instanceof Element) { - appInfo.appendChild(cloneElement(doc, (Element) childs.item(i))); - } - } - } - - private static Element cloneElement(Document doc, Element base) { - // Element copy = doc.createElementNS(tagretNamespace,prefix+ ":" + - // base.getLocalName()); - Element copy = doc.createElementNS(base.getNamespaceURI(), base.getTagName()); - - NodeList nodes = base.getChildNodes(); - for (int i = 0; i < nodes.getLength(); i++) { - Node node = nodes.item(i); - switch (node.getNodeType()) { - case Node.COMMENT_NODE: - Comment comment = (Comment) node; - copy.appendChild(doc.createComment(comment.getData())); - break; - case Node.ELEMENT_NODE: - copy.appendChild(cloneElement(doc, (Element) node)); - break; - case Node.ATTRIBUTE_NODE: - Attr attr = (Attr) node; - Attr attrCopy = doc.createAttributeNS(attr.getNamespaceURI(), attr.getPrefix() + ":" + attr.getName()); - attrCopy.setValue(attr.getValue()); - copy.appendChild(attrCopy); - break; - case Node.TEXT_NODE: - copy.appendChild(doc.createTextNode(((Text) node).getNodeValue())); - break; - default: - break; - } - } - return copy; - - } - -} \ No newline at end of file
