http://git-wip-us.apache.org/repos/asf/cxf/blob/517ef67f/rt/ws/transfer/src/main/java/org/apache/cxf/ws/transfer/resource/ResourceRemote.java ---------------------------------------------------------------------- diff --git a/rt/ws/transfer/src/main/java/org/apache/cxf/ws/transfer/resource/ResourceRemote.java b/rt/ws/transfer/src/main/java/org/apache/cxf/ws/transfer/resource/ResourceRemote.java new file mode 100644 index 0000000..52916ea --- /dev/null +++ b/rt/ws/transfer/src/main/java/org/apache/cxf/ws/transfer/resource/ResourceRemote.java @@ -0,0 +1,49 @@ +/** + * 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.cxf.ws.transfer.resource; + +import org.apache.cxf.ws.addressing.EndpointReferenceType; +import org.apache.cxf.ws.addressing.ReferenceParametersType; +import org.apache.cxf.ws.transfer.Create; +import org.apache.cxf.ws.transfer.CreateResponse; +import org.apache.cxf.ws.transfer.Representation; +import org.apache.cxf.ws.transfer.resourcefactory.ResourceFactory; +import org.apache.cxf.ws.transfer.validationtransformation.ValidAndTransformHelper; + +/** + * Implementation of the Resource interface for resources, which are created remotely. + * @see org.apache.cxf.ws.transfer.resourcefactory.resolver.ResourceResolver + */ +public class ResourceRemote extends ResourceLocal implements ResourceFactory { + + @Override + public CreateResponse create(Create body) { + Representation representation = body.getRepresentation(); + ValidAndTransformHelper.validationAndTransformation( + getResourceTypeIdentifiers(), representation, null); + ReferenceParametersType refParams = getManager().create(representation); + CreateResponse response = new CreateResponse(); + response.setResourceCreated(new EndpointReferenceType()); + response.getResourceCreated().setReferenceParameters(refParams); + response.setRepresentation(body.getRepresentation()); + return response; + } + +}
http://git-wip-us.apache.org/repos/asf/cxf/blob/517ef67f/rt/ws/transfer/src/main/java/org/apache/cxf/ws/transfer/resourcefactory/ResourceFactory.java ---------------------------------------------------------------------- diff --git a/rt/ws/transfer/src/main/java/org/apache/cxf/ws/transfer/resourcefactory/ResourceFactory.java b/rt/ws/transfer/src/main/java/org/apache/cxf/ws/transfer/resourcefactory/ResourceFactory.java new file mode 100644 index 0000000..da28d43 --- /dev/null +++ b/rt/ws/transfer/src/main/java/org/apache/cxf/ws/transfer/resourcefactory/ResourceFactory.java @@ -0,0 +1,61 @@ +/** + * 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.cxf.ws.transfer.resourcefactory; + +import javax.jws.WebMethod; +import javax.jws.WebParam; +import javax.jws.WebResult; +import javax.jws.WebService; +import javax.jws.soap.SOAPBinding; +import javax.xml.ws.Action; +import javax.xml.ws.soap.Addressing; +import org.apache.cxf.ws.transfer.Create; +import org.apache.cxf.ws.transfer.CreateResponse; +import org.apache.cxf.ws.transfer.shared.TransferConstants; + +/** + * The interface definition of a Resource Factory web service, according to the specification. + */ + +@WebService(targetNamespace = TransferConstants.TRANSFER_2011_03_NAMESPACE, + name = TransferConstants.NAME_RESOURCE_FACTORY) +@SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE) +@Addressing(enabled = true, required = true) +public interface ResourceFactory { + @Action( + input = TransferConstants.ACTION_CREATE, + output = TransferConstants.ACTION_CREATE_RESPONSE + ) + @WebMethod(operationName = TransferConstants.NAME_OPERATION_CREATE) + @WebResult( + name = TransferConstants.NAME_MESSAGE_CREATE_RESPONSE, + targetNamespace = TransferConstants.TRANSFER_2011_03_NAMESPACE, + partName = "Body" + ) + CreateResponse create( + @WebParam( + name = TransferConstants.NAME_MESSAGE_CREATE, + targetNamespace = TransferConstants.TRANSFER_2011_03_NAMESPACE, + partName = "Body" + ) + Create body + ); +} http://git-wip-us.apache.org/repos/asf/cxf/blob/517ef67f/rt/ws/transfer/src/main/java/org/apache/cxf/ws/transfer/resourcefactory/ResourceFactoryImpl.java ---------------------------------------------------------------------- diff --git a/rt/ws/transfer/src/main/java/org/apache/cxf/ws/transfer/resourcefactory/ResourceFactoryImpl.java b/rt/ws/transfer/src/main/java/org/apache/cxf/ws/transfer/resourcefactory/ResourceFactoryImpl.java new file mode 100644 index 0000000..32ca4f6 --- /dev/null +++ b/rt/ws/transfer/src/main/java/org/apache/cxf/ws/transfer/resourcefactory/ResourceFactoryImpl.java @@ -0,0 +1,153 @@ +/** + * 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.cxf.ws.transfer.resourcefactory; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import org.apache.cxf.interceptor.LoggingInInterceptor; +import org.apache.cxf.interceptor.LoggingOutInterceptor; +import org.apache.cxf.jaxws.JaxWsProxyFactoryBean; +import org.apache.cxf.ws.addressing.AttributedURIType; +import org.apache.cxf.ws.addressing.EndpointReferenceType; +import org.apache.cxf.ws.addressing.ReferenceParametersType; +import org.apache.cxf.ws.transfer.Create; +import org.apache.cxf.ws.transfer.CreateResponse; +import org.apache.cxf.ws.transfer.Representation; +import org.apache.cxf.ws.transfer.dialect.Dialect; +import org.apache.cxf.ws.transfer.resourcefactory.resolver.ResourceReference; +import org.apache.cxf.ws.transfer.resourcefactory.resolver.ResourceResolver; +import org.apache.cxf.ws.transfer.shared.TransferConstants; +import org.apache.cxf.ws.transfer.shared.faults.UnknownDialect; +import org.apache.cxf.ws.transfer.validationtransformation.ResourceTypeIdentifier; +import org.apache.cxf.ws.transfer.validationtransformation.ValidAndTransformHelper; + +/** + * ResourceFactory implementation. + */ +public class ResourceFactoryImpl implements ResourceFactory { + + protected ResourceResolver resourceResolver; + + protected List<ResourceTypeIdentifier> resourceTypeIdentifiers; + + protected Map<String, Dialect> dialects; + + public ResourceFactoryImpl() { + dialects = new HashMap<String, Dialect>(); + } + + @Override + public CreateResponse create(Create body) { + if (body.getDialect() != null && !body.getDialect().isEmpty()) { + if (dialects.containsKey(body.getDialect())) { + Dialect dialect = dialects.get(body.getDialect()); + Representation representation = dialect.processCreate(body); + body.setRepresentation(representation); + } else { + throw new UnknownDialect(); + } + } + ValidAndTransformHelper.validationAndTransformation( + resourceTypeIdentifiers, body.getRepresentation(), null); + + ResourceReference resourceReference = resourceResolver.resolve(body); + if (resourceReference.getResourceManager() != null) { + return createLocally(body, resourceReference); + } else { + return createRemotely(body, resourceReference); + } + } + + public ResourceResolver getResourceResolver() { + return resourceResolver; + } + + public void setResourceResolver(ResourceResolver resourceResolver) { + this.resourceResolver = resourceResolver; + } + + public List<ResourceTypeIdentifier> getResourceTypeIdentifiers() { + if (resourceTypeIdentifiers == null) { + resourceTypeIdentifiers = new ArrayList<>(); + } + return resourceTypeIdentifiers; + } + + public void setResourceTypeIdentifiers(List<ResourceTypeIdentifier> resourceTypeIdentifiers) { + this.resourceTypeIdentifiers = resourceTypeIdentifiers; + } + + /** + * Register Dialect object for URI. + * @param uri + * @param dialect + */ + public void registerDialect(String uri, Dialect dialect) { + if (dialects.containsKey(uri)) { + throw new IllegalArgumentException(String.format("URI \"%s\" is already registered", uri)); + } + dialects.put(uri, dialect); + } + + /** + * Unregister dialect URI. + * @param uri + */ + public void unregisterDialect(String uri) { + if (!dialects.containsKey(uri)) { + throw new IllegalArgumentException(String.format("URI \"%s\" is not registered", uri)); + } + dialects.remove(uri); + } + + private CreateResponse createLocally(Create body, ResourceReference ref) { + Representation representation = body.getRepresentation(); + ReferenceParametersType refParams = ref.getResourceManager().create(representation); + + CreateResponse response = new CreateResponse(); + response.setResourceCreated(new EndpointReferenceType()); + response.getResourceCreated().setAddress(new AttributedURIType()); + response.getResourceCreated() + .getAddress() + .setValue(ref.getResourceURL()); + response.getResourceCreated() + .setReferenceParameters(refParams); + response.setRepresentation(body.getRepresentation()); + + return response; + } + + private CreateResponse createRemotely(Create body, ResourceReference ref) { + JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean(); + factory.getInInterceptors().add(new LoggingInInterceptor()); + factory.getOutInterceptors().add(new LoggingOutInterceptor()); + factory.setServiceClass(ResourceFactory.class); + factory.setAddress(ref.getResourceURL() + + TransferConstants.RESOURCE_REMOTE_SUFFIX); + ResourceFactory client = (ResourceFactory) factory.create(); + CreateResponse response = client.create(body); + // Adding of endpoint address to the response. + response.getResourceCreated().setAddress(new AttributedURIType()); + response.getResourceCreated().getAddress().setValue(ref.getResourceURL()); + return response; + } +} http://git-wip-us.apache.org/repos/asf/cxf/blob/517ef67f/rt/ws/transfer/src/main/java/org/apache/cxf/ws/transfer/resourcefactory/resolver/ResourceReference.java ---------------------------------------------------------------------- diff --git a/rt/ws/transfer/src/main/java/org/apache/cxf/ws/transfer/resourcefactory/resolver/ResourceReference.java b/rt/ws/transfer/src/main/java/org/apache/cxf/ws/transfer/resourcefactory/resolver/ResourceReference.java new file mode 100644 index 0000000..1e86030 --- /dev/null +++ b/rt/ws/transfer/src/main/java/org/apache/cxf/ws/transfer/resourcefactory/resolver/ResourceReference.java @@ -0,0 +1,61 @@ +/** + * 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.cxf.ws.transfer.resourcefactory.resolver; + +import org.apache.cxf.ws.transfer.manager.ResourceManager; + +/** + * Class intended as return value from the ResourceResolver. + * @see ResourceResolver + */ +public class ResourceReference { + + private ResourceManager resourceManager; + + private String resourceURL; + + public ResourceReference() { + + } + + public ResourceReference( + String resourceURL, + ResourceManager resourceManager) { + this.resourceURL = resourceURL; + this.resourceManager = resourceManager; + } + + public ResourceManager getResourceManager() { + return resourceManager; + } + + public void setResourceManager(ResourceManager resourceManager) { + this.resourceManager = resourceManager; + } + + public String getResourceURL() { + return resourceURL; + } + + public void setResourceURL(String resourceURL) { + this.resourceURL = resourceURL; + } + +} http://git-wip-us.apache.org/repos/asf/cxf/blob/517ef67f/rt/ws/transfer/src/main/java/org/apache/cxf/ws/transfer/resourcefactory/resolver/ResourceResolver.java ---------------------------------------------------------------------- diff --git a/rt/ws/transfer/src/main/java/org/apache/cxf/ws/transfer/resourcefactory/resolver/ResourceResolver.java b/rt/ws/transfer/src/main/java/org/apache/cxf/ws/transfer/resourcefactory/resolver/ResourceResolver.java new file mode 100644 index 0000000..6e4339c --- /dev/null +++ b/rt/ws/transfer/src/main/java/org/apache/cxf/ws/transfer/resourcefactory/resolver/ResourceResolver.java @@ -0,0 +1,39 @@ +/** + * 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.cxf.ws.transfer.resourcefactory.resolver; + +import org.apache.cxf.ws.transfer.Create; + +/** + * The interface for resolving, where the Resource will be created. + */ +public interface ResourceResolver { + + /** + * Method for resolving, where the Resource will be created. + * @param body SOAP body + * @return ResourceReference object. If the Resource should be created locally, + * so the ResourceReference object must contain address and reference to the + * ResourceManager object. Otherwise the ResourceReference must contain only + * the address to the ResourceRemote endpoint. + */ + ResourceReference resolve(Create body); + +} http://git-wip-us.apache.org/repos/asf/cxf/blob/517ef67f/rt/ws/transfer/src/main/java/org/apache/cxf/ws/transfer/resourcefactory/resolver/SimpleResourceResolver.java ---------------------------------------------------------------------- diff --git a/rt/ws/transfer/src/main/java/org/apache/cxf/ws/transfer/resourcefactory/resolver/SimpleResourceResolver.java b/rt/ws/transfer/src/main/java/org/apache/cxf/ws/transfer/resourcefactory/resolver/SimpleResourceResolver.java new file mode 100644 index 0000000..c988319 --- /dev/null +++ b/rt/ws/transfer/src/main/java/org/apache/cxf/ws/transfer/resourcefactory/resolver/SimpleResourceResolver.java @@ -0,0 +1,69 @@ +/** + * 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.cxf.ws.transfer.resourcefactory.resolver; + +import org.apache.cxf.ws.transfer.Create; +import org.apache.cxf.ws.transfer.manager.ResourceManager; + +/** + * The simple ResourceResolver, which always returns a predefined resource + * location. + */ +public class SimpleResourceResolver implements ResourceResolver { + + protected ResourceManager resourceManager; + + protected String resourceURL; + + public SimpleResourceResolver() { + + } + + public SimpleResourceResolver(String resourceURL) { + this.resourceURL = resourceURL; + } + + public SimpleResourceResolver(String resourceURL, ResourceManager resourceManager) { + this.resourceURL = resourceURL; + this.resourceManager = resourceManager; + } + + @Override + public ResourceReference resolve(Create body) { + return new ResourceReference(resourceURL, resourceManager); + } + + public String getResourceURL() { + return resourceURL; + } + + public void setResourceURL(String resourceURL) { + this.resourceURL = resourceURL; + } + + public ResourceManager getResourceManager() { + return resourceManager; + } + + public void setResourceManager(ResourceManager resourceManager) { + this.resourceManager = resourceManager; + } + +} http://git-wip-us.apache.org/repos/asf/cxf/blob/517ef67f/rt/ws/transfer/src/main/java/org/apache/cxf/ws/transfer/shared/TransferConstants.java ---------------------------------------------------------------------- diff --git a/rt/ws/transfer/src/main/java/org/apache/cxf/ws/transfer/shared/TransferConstants.java b/rt/ws/transfer/src/main/java/org/apache/cxf/ws/transfer/shared/TransferConstants.java new file mode 100644 index 0000000..3da2107 --- /dev/null +++ b/rt/ws/transfer/src/main/java/org/apache/cxf/ws/transfer/shared/TransferConstants.java @@ -0,0 +1,60 @@ +/** + * 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.cxf.ws.transfer.shared; + +/** + * Helper class for holding of constants. + */ +public final class TransferConstants { + + public static final String TRANSFER_2011_03_NAMESPACE = "http://www.w3.org/2011/03/ws-tra"; + + public static final String NAME_RESOURCE = "Resource"; + public static final String NAME_RESOURCE_FACTORY = "ResourceFactory"; + + public static final String NAME_OPERATION_GET = "Get"; + public static final String NAME_OPERATION_DELETE = "Delete"; + public static final String NAME_OPERATION_PUT = "Put"; + public static final String NAME_OPERATION_CREATE = "Create"; + + public static final String NAME_MESSAGE_GET = "Get"; + public static final String NAME_MESSAGE_GET_RESPONSE = "GetResponse"; + public static final String NAME_MESSAGE_DELETE = "Delete"; + public static final String NAME_MESSAGE_DELETE_RESPONSE = "DeleteResponse"; + public static final String NAME_MESSAGE_PUT = "Put"; + public static final String NAME_MESSAGE_PUT_RESPONSE = "PutResponse"; + public static final String NAME_MESSAGE_CREATE = "Create"; + public static final String NAME_MESSAGE_CREATE_RESPONSE = "CreateResponse"; + + public static final String ACTION_GET = "http://www.w3.org/2011/03/ws-tra/Get"; + public static final String ACTION_GET_RESPONSE = "http://www.w3.org/2011/03/ws-tra/GetResponse"; + public static final String ACTION_DELETE = "http://www.w3.org/2011/03/ws-tra/Delete"; + public static final String ACTION_DELETE_RESPONSE = "http://www.w3.org/2011/03/ws-tra/DeleteResponse"; + public static final String ACTION_PUT = "http://www.w3.org/2011/03/ws-tra/Put"; + public static final String ACTION_PUT_RESPONSE = "http://www.w3.org/2011/03/ws-tra/PutResponse"; + public static final String ACTION_CREATE = "http://www.w3.org/2011/03/ws-tra/Create"; + public static final String ACTION_CREATE_RESPONSE = "http://www.w3.org/2011/03/ws-tra/CreateResponse"; + + public static final String RESOURCE_REMOTE_SUFFIX = "_factory"; + + private TransferConstants() { + + } +} http://git-wip-us.apache.org/repos/asf/cxf/blob/517ef67f/rt/ws/transfer/src/main/java/org/apache/cxf/ws/transfer/shared/faults/InvalidRepresentation.java ---------------------------------------------------------------------- diff --git a/rt/ws/transfer/src/main/java/org/apache/cxf/ws/transfer/shared/faults/InvalidRepresentation.java b/rt/ws/transfer/src/main/java/org/apache/cxf/ws/transfer/shared/faults/InvalidRepresentation.java new file mode 100644 index 0000000..21ea6c3 --- /dev/null +++ b/rt/ws/transfer/src/main/java/org/apache/cxf/ws/transfer/shared/faults/InvalidRepresentation.java @@ -0,0 +1,41 @@ +/** + * 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.cxf.ws.transfer.shared.faults; + +import javax.xml.namespace.QName; +import org.apache.cxf.ws.transfer.shared.TransferConstants; + +/** + * Definition of the InvalidRepresentation SOAPFault. + */ +public class InvalidRepresentation extends WSTransferFault { + + private static final long serialVersionUID = 330259919571428100L; + + private static final String SUBCODE = "InvalidRepresentation"; + + private static final String REASON = "The supplied representation is invalid"; + + public InvalidRepresentation() { + super(REASON, null, + new QName(TransferConstants.TRANSFER_2011_03_NAMESPACE, SUBCODE)); + } + +} http://git-wip-us.apache.org/repos/asf/cxf/blob/517ef67f/rt/ws/transfer/src/main/java/org/apache/cxf/ws/transfer/shared/faults/PutDenied.java ---------------------------------------------------------------------- diff --git a/rt/ws/transfer/src/main/java/org/apache/cxf/ws/transfer/shared/faults/PutDenied.java b/rt/ws/transfer/src/main/java/org/apache/cxf/ws/transfer/shared/faults/PutDenied.java new file mode 100644 index 0000000..b0c6ad6 --- /dev/null +++ b/rt/ws/transfer/src/main/java/org/apache/cxf/ws/transfer/shared/faults/PutDenied.java @@ -0,0 +1,44 @@ +/** + * 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.cxf.ws.transfer.shared.faults; + +import javax.xml.namespace.QName; +import org.apache.cxf.ws.transfer.shared.TransferConstants; + +/** + * Definition of the PutDenied SOAPFault. + */ +public class PutDenied extends WSTransferFault { + + private static final long serialVersionUID = -6644888926499946963L; + + private static final String SUBCODE = "UpdateDenied"; + + private static final String REASON = "One or more elements or attributes cannot be updated."; + + private static final String DETAIL = + "An OPTIONAL list of the QNames of the elements or attributes that are not allowed to be updated."; + + public PutDenied() { + super(REASON, DETAIL, + new QName(TransferConstants.TRANSFER_2011_03_NAMESPACE, SUBCODE)); + } + +} http://git-wip-us.apache.org/repos/asf/cxf/blob/517ef67f/rt/ws/transfer/src/main/java/org/apache/cxf/ws/transfer/shared/faults/UnknownDialect.java ---------------------------------------------------------------------- diff --git a/rt/ws/transfer/src/main/java/org/apache/cxf/ws/transfer/shared/faults/UnknownDialect.java b/rt/ws/transfer/src/main/java/org/apache/cxf/ws/transfer/shared/faults/UnknownDialect.java new file mode 100644 index 0000000..5c9f9ea --- /dev/null +++ b/rt/ws/transfer/src/main/java/org/apache/cxf/ws/transfer/shared/faults/UnknownDialect.java @@ -0,0 +1,43 @@ +/** + * 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.cxf.ws.transfer.shared.faults; + +import javax.xml.namespace.QName; +import org.apache.cxf.ws.transfer.shared.TransferConstants; + +/** + * Definition of the UnknownDialect SOAPFault. + */ +public class UnknownDialect extends WSTransferFault { + + private static final long serialVersionUID = 7139243705016686015L; + + private static final String SUBCODE = "UnknownDialect"; + + private static final String REASON = "The specified Dialect IRI is not known."; + + private static final String DETAIL = "The unknown IRI if specified"; + + public UnknownDialect() { + super(REASON, DETAIL, + new QName(TransferConstants.TRANSFER_2011_03_NAMESPACE, SUBCODE)); + } + +} http://git-wip-us.apache.org/repos/asf/cxf/blob/517ef67f/rt/ws/transfer/src/main/java/org/apache/cxf/ws/transfer/shared/faults/UnknownResource.java ---------------------------------------------------------------------- diff --git a/rt/ws/transfer/src/main/java/org/apache/cxf/ws/transfer/shared/faults/UnknownResource.java b/rt/ws/transfer/src/main/java/org/apache/cxf/ws/transfer/shared/faults/UnknownResource.java new file mode 100644 index 0000000..1b3c61d --- /dev/null +++ b/rt/ws/transfer/src/main/java/org/apache/cxf/ws/transfer/shared/faults/UnknownResource.java @@ -0,0 +1,42 @@ +/** + * 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.cxf.ws.transfer.shared.faults; + +import javax.xml.namespace.QName; +import org.apache.cxf.ws.transfer.shared.TransferConstants; + +/** + * This fault MUST be generated when a request specifies a resource + * that is not known. + */ +public class UnknownResource extends WSTransferFault { + + private static final long serialVersionUID = 2925090710469446447L; + + private static final String SUBCODE = "UnknownResource"; + + private static final String REASON = "The resource is not known."; + + public UnknownResource() { + super(REASON, null, + new QName(TransferConstants.TRANSFER_2011_03_NAMESPACE, SUBCODE)); + } + +} http://git-wip-us.apache.org/repos/asf/cxf/blob/517ef67f/rt/ws/transfer/src/main/java/org/apache/cxf/ws/transfer/shared/faults/WSTransferFault.java ---------------------------------------------------------------------- diff --git a/rt/ws/transfer/src/main/java/org/apache/cxf/ws/transfer/shared/faults/WSTransferFault.java b/rt/ws/transfer/src/main/java/org/apache/cxf/ws/transfer/shared/faults/WSTransferFault.java new file mode 100644 index 0000000..673da39 --- /dev/null +++ b/rt/ws/transfer/src/main/java/org/apache/cxf/ws/transfer/shared/faults/WSTransferFault.java @@ -0,0 +1,45 @@ +/** + * 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.cxf.ws.transfer.shared.faults; + +import javax.xml.namespace.QName; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.apache.cxf.binding.soap.SoapFault; +import org.apache.cxf.helpers.DOMUtils; + +/** + * The parent for all WS-Transfer-specific faults. + */ +public abstract class WSTransferFault extends SoapFault { + + private static final long serialVersionUID = -7603229392321418734L; + + public WSTransferFault(String reason, String detail, QName faultCode) { + super(reason, faultCode); + if (detail != null) { + Document doc = DOMUtils.createDocument(); + Element detailEl = doc.createElement("detail"); + detailEl.setTextContent(detail); + setDetail(detailEl); + } + } + +} http://git-wip-us.apache.org/repos/asf/cxf/blob/517ef67f/rt/ws/transfer/src/main/java/org/apache/cxf/ws/transfer/validationtransformation/ResourceTransformer.java ---------------------------------------------------------------------- diff --git a/rt/ws/transfer/src/main/java/org/apache/cxf/ws/transfer/validationtransformation/ResourceTransformer.java b/rt/ws/transfer/src/main/java/org/apache/cxf/ws/transfer/validationtransformation/ResourceTransformer.java new file mode 100644 index 0000000..69cdb20 --- /dev/null +++ b/rt/ws/transfer/src/main/java/org/apache/cxf/ws/transfer/validationtransformation/ResourceTransformer.java @@ -0,0 +1,30 @@ +/** + * 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.cxf.ws.transfer.validationtransformation; + +import org.apache.cxf.ws.transfer.Representation; + +/** + * The interface for a Transformer objects. + */ +public interface ResourceTransformer { + + ResourceValidator transform(Representation newRepresentation, Representation oldRepresentation); +} http://git-wip-us.apache.org/repos/asf/cxf/blob/517ef67f/rt/ws/transfer/src/main/java/org/apache/cxf/ws/transfer/validationtransformation/ResourceTypeIdentifier.java ---------------------------------------------------------------------- diff --git a/rt/ws/transfer/src/main/java/org/apache/cxf/ws/transfer/validationtransformation/ResourceTypeIdentifier.java b/rt/ws/transfer/src/main/java/org/apache/cxf/ws/transfer/validationtransformation/ResourceTypeIdentifier.java new file mode 100644 index 0000000..f04e774 --- /dev/null +++ b/rt/ws/transfer/src/main/java/org/apache/cxf/ws/transfer/validationtransformation/ResourceTypeIdentifier.java @@ -0,0 +1,36 @@ +/** + * 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.cxf.ws.transfer.validationtransformation; + +import org.apache.cxf.ws.transfer.Representation; + +/** + * The interface for TypeIdentifier objects. + */ +public interface ResourceTypeIdentifier { + + /** + * Returns true if the representation corresponds to type, which object represents. + * @param representation + * @return + */ + ResourceTypeIdentifierResult identify(Representation representation); + +} http://git-wip-us.apache.org/repos/asf/cxf/blob/517ef67f/rt/ws/transfer/src/main/java/org/apache/cxf/ws/transfer/validationtransformation/ResourceTypeIdentifierResult.java ---------------------------------------------------------------------- diff --git a/rt/ws/transfer/src/main/java/org/apache/cxf/ws/transfer/validationtransformation/ResourceTypeIdentifierResult.java b/rt/ws/transfer/src/main/java/org/apache/cxf/ws/transfer/validationtransformation/ResourceTypeIdentifierResult.java new file mode 100644 index 0000000..c8999c0 --- /dev/null +++ b/rt/ws/transfer/src/main/java/org/apache/cxf/ws/transfer/validationtransformation/ResourceTypeIdentifierResult.java @@ -0,0 +1,56 @@ +/** + * 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.cxf.ws.transfer.validationtransformation; + +/** + * This class represents the result from the ResourceTypeIdentifier. + */ +public class ResourceTypeIdentifierResult { + + private boolean correct; + + private ResourceTransformer transformer; + + public ResourceTypeIdentifierResult() { + + } + + public ResourceTypeIdentifierResult(boolean result, ResourceTransformer transformer) { + this.correct = result; + this.transformer = transformer; + } + + public boolean isCorrect() { + return correct; + } + + public void setCorrect(boolean correct) { + this.correct = correct; + } + + public ResourceTransformer getTransformer() { + return transformer; + } + + public void setTransformer(ResourceTransformer transformer) { + this.transformer = transformer; + } + +} http://git-wip-us.apache.org/repos/asf/cxf/blob/517ef67f/rt/ws/transfer/src/main/java/org/apache/cxf/ws/transfer/validationtransformation/ResourceValidator.java ---------------------------------------------------------------------- diff --git a/rt/ws/transfer/src/main/java/org/apache/cxf/ws/transfer/validationtransformation/ResourceValidator.java b/rt/ws/transfer/src/main/java/org/apache/cxf/ws/transfer/validationtransformation/ResourceValidator.java new file mode 100644 index 0000000..b31ec29 --- /dev/null +++ b/rt/ws/transfer/src/main/java/org/apache/cxf/ws/transfer/validationtransformation/ResourceValidator.java @@ -0,0 +1,31 @@ +/** + * 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.cxf.ws.transfer.validationtransformation; + +import org.apache.cxf.ws.transfer.Representation; + +/** + * The interface for Validator objects. + */ +public interface ResourceValidator { + + boolean validate(Representation newRepresentation, Representation oldRepresentation); + +} http://git-wip-us.apache.org/repos/asf/cxf/blob/517ef67f/rt/ws/transfer/src/main/java/org/apache/cxf/ws/transfer/validationtransformation/ValidAndTransformHelper.java ---------------------------------------------------------------------- diff --git a/rt/ws/transfer/src/main/java/org/apache/cxf/ws/transfer/validationtransformation/ValidAndTransformHelper.java b/rt/ws/transfer/src/main/java/org/apache/cxf/ws/transfer/validationtransformation/ValidAndTransformHelper.java new file mode 100644 index 0000000..4c806ef --- /dev/null +++ b/rt/ws/transfer/src/main/java/org/apache/cxf/ws/transfer/validationtransformation/ValidAndTransformHelper.java @@ -0,0 +1,63 @@ +/** + * 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.cxf.ws.transfer.validationtransformation; + +import java.util.List; +import org.apache.cxf.ws.transfer.Representation; +import org.apache.cxf.ws.transfer.shared.faults.InvalidRepresentation; + +/** + * Helper class for validation and transformation. + */ +public final class ValidAndTransformHelper { + + private ValidAndTransformHelper() { + + } + + /** + * Validation and transformation process. + * @param resourceTypeIdentifiers List of resourceTypeIdentifiers. + * @param newRepresentation Incoming representation. + * @param oldRepresentation Representation stored in the ResourceManager. + */ + public static void validationAndTransformation( + List<ResourceTypeIdentifier> resourceTypeIdentifiers, + Representation newRepresentation, + Representation oldRepresentation) { + if (resourceTypeIdentifiers != null && !resourceTypeIdentifiers.isEmpty()) { + for (ResourceTypeIdentifier resourceIdentifier : resourceTypeIdentifiers) { + ResourceTypeIdentifierResult valResult = resourceIdentifier.identify(newRepresentation); + if (valResult.isCorrect()) { + if (valResult.getTransformer() != null) { + ResourceTransformer transformer = valResult.getTransformer(); + ResourceValidator validator = transformer.transform(newRepresentation, oldRepresentation); + if (validator != null && !validator.validate(newRepresentation, oldRepresentation)) { + throw new InvalidRepresentation(); + } + } + return; + } + } + throw new InvalidRepresentation(); + } + } + +} http://git-wip-us.apache.org/repos/asf/cxf/blob/517ef67f/rt/ws/transfer/src/main/java/org/apache/cxf/ws/transfer/validationtransformation/XSDResourceTypeIdentifier.java ---------------------------------------------------------------------- diff --git a/rt/ws/transfer/src/main/java/org/apache/cxf/ws/transfer/validationtransformation/XSDResourceTypeIdentifier.java b/rt/ws/transfer/src/main/java/org/apache/cxf/ws/transfer/validationtransformation/XSDResourceTypeIdentifier.java new file mode 100644 index 0000000..a6b5505 --- /dev/null +++ b/rt/ws/transfer/src/main/java/org/apache/cxf/ws/transfer/validationtransformation/XSDResourceTypeIdentifier.java @@ -0,0 +1,87 @@ +/** + * 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.cxf.ws.transfer.validationtransformation; + +import java.io.IOException; +import java.util.logging.Logger; + +import javax.annotation.Resource; +import javax.xml.XMLConstants; +import javax.xml.transform.Source; +import javax.xml.transform.dom.DOMSource; +import javax.xml.validation.Schema; +import javax.xml.validation.SchemaFactory; +import javax.xml.validation.Validator; +import javax.xml.ws.WebServiceContext; + +import org.w3c.dom.Node; +import org.xml.sax.SAXException; +import org.apache.cxf.binding.soap.SoapFault; +import org.apache.cxf.binding.soap.SoapMessage; +import org.apache.cxf.binding.soap.SoapVersion; +import org.apache.cxf.common.logging.LogUtils; +import org.apache.cxf.jaxws.context.WrappedMessageContext; +import org.apache.cxf.ws.transfer.Representation; + +/** + * Implementation of the ResourceTypeIdentifier interface using by XSDSchema validation. + */ +public class XSDResourceTypeIdentifier implements ResourceTypeIdentifier { + + private static final Logger LOG = LogUtils.getL7dLogger(XSDResourceTypeIdentifier.class); + + protected ResourceTransformer resourceTransformer; + + protected Validator validator; + + @Resource + private WebServiceContext context; + + public XSDResourceTypeIdentifier(Source xsd, ResourceTransformer resourceTransformer) { + try { + this.resourceTransformer = resourceTransformer; + SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); + Schema schema = schemaFactory.newSchema(xsd); + this.validator = schema.newValidator(); + } catch (SAXException ex) { + LOG.severe(ex.getLocalizedMessage()); + throw new SoapFault("Internal error", getSoapVersion().getReceiver()); + } + } + + @Override + public ResourceTypeIdentifierResult identify(Representation representation) { + try { + validator.validate(new DOMSource((Node) representation.getAny())); + } catch (SAXException ex) { + return new ResourceTypeIdentifierResult(false, resourceTransformer); + } catch (IOException ex) { + LOG.severe(ex.getLocalizedMessage()); + throw new SoapFault("Internal error", getSoapVersion().getReceiver()); + } + return new ResourceTypeIdentifierResult(true, resourceTransformer); + } + + private SoapVersion getSoapVersion() { + WrappedMessageContext wmc = (WrappedMessageContext) context.getMessageContext(); + SoapMessage message = (SoapMessage) wmc.getWrappedMessage(); + return message.getVersion(); + } +} http://git-wip-us.apache.org/repos/asf/cxf/blob/517ef67f/rt/ws/transfer/src/main/java/org/apache/cxf/ws/transfer/validationtransformation/XSDResourceValidator.java ---------------------------------------------------------------------- diff --git a/rt/ws/transfer/src/main/java/org/apache/cxf/ws/transfer/validationtransformation/XSDResourceValidator.java b/rt/ws/transfer/src/main/java/org/apache/cxf/ws/transfer/validationtransformation/XSDResourceValidator.java new file mode 100644 index 0000000..f5da781 --- /dev/null +++ b/rt/ws/transfer/src/main/java/org/apache/cxf/ws/transfer/validationtransformation/XSDResourceValidator.java @@ -0,0 +1,88 @@ +/** + * 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.cxf.ws.transfer.validationtransformation; + +import java.io.IOException; +import java.util.logging.Logger; + +import javax.annotation.Resource; +import javax.xml.XMLConstants; +import javax.xml.transform.Source; +import javax.xml.transform.dom.DOMSource; +import javax.xml.validation.Schema; +import javax.xml.validation.SchemaFactory; +import javax.xml.validation.Validator; +import javax.xml.ws.WebServiceContext; + +import org.w3c.dom.Node; +import org.xml.sax.SAXException; +import org.apache.cxf.binding.soap.SoapFault; +import org.apache.cxf.binding.soap.SoapMessage; +import org.apache.cxf.binding.soap.SoapVersion; +import org.apache.cxf.common.logging.LogUtils; +import org.apache.cxf.jaxws.context.WrappedMessageContext; +import org.apache.cxf.ws.transfer.Representation; + +/** + * Implementation of the ResourceValidator interface for Schema validation. + */ +public class XSDResourceValidator implements ResourceValidator { + + private static final Logger LOG = LogUtils.getL7dLogger(XSDResourceValidator.class); + + protected Validator validator; + + @Resource + private WebServiceContext context; + + public XSDResourceValidator(Source xsd, ResourceTransformer resourceTransformer) { + try { + SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); + Schema schema = schemaFactory.newSchema(xsd); + this.validator = schema.newValidator(); + } catch (SAXException ex) { + LOG.severe(ex.getLocalizedMessage()); + throw new SoapFault("Internal error", getSoapVersion().getReceiver()); + } + } + + public XSDResourceValidator(Source xsd) { + this(xsd, null); + } + + @Override + public boolean validate(Representation representation, Representation oldRepresentation) { + try { + validator.validate(new DOMSource((Node) representation.getAny())); + } catch (SAXException ex) { + return false; + } catch (IOException ex) { + LOG.severe(ex.getLocalizedMessage()); + throw new SoapFault("Internal error", getSoapVersion().getReceiver()); + } + return true; + } + + private SoapVersion getSoapVersion() { + WrappedMessageContext wmc = (WrappedMessageContext) context.getMessageContext(); + SoapMessage message = (SoapMessage) wmc.getWrappedMessage(); + return message.getVersion(); + } +} http://git-wip-us.apache.org/repos/asf/cxf/blob/517ef67f/rt/ws/transfer/src/main/java/org/apache/cxf/ws/transfer/validationtransformation/XSLTResourceTransformer.java ---------------------------------------------------------------------- diff --git a/rt/ws/transfer/src/main/java/org/apache/cxf/ws/transfer/validationtransformation/XSLTResourceTransformer.java b/rt/ws/transfer/src/main/java/org/apache/cxf/ws/transfer/validationtransformation/XSLTResourceTransformer.java new file mode 100644 index 0000000..0538dd3 --- /dev/null +++ b/rt/ws/transfer/src/main/java/org/apache/cxf/ws/transfer/validationtransformation/XSLTResourceTransformer.java @@ -0,0 +1,87 @@ +/** + * 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.cxf.ws.transfer.validationtransformation; + +import java.util.logging.Logger; + +import javax.annotation.Resource; +import javax.xml.transform.Source; +import javax.xml.transform.Templates; +import javax.xml.transform.TransformerConfigurationException; +import javax.xml.transform.TransformerFactory; +import javax.xml.ws.WebServiceContext; + +import org.w3c.dom.Document; +import org.w3c.dom.Node; +import org.apache.cxf.binding.soap.SoapFault; +import org.apache.cxf.binding.soap.SoapMessage; +import org.apache.cxf.binding.soap.SoapVersion; +import org.apache.cxf.common.logging.LogUtils; +import org.apache.cxf.feature.transform.XSLTUtils; +import org.apache.cxf.helpers.DOMUtils; +import org.apache.cxf.jaxws.context.WrappedMessageContext; +import org.apache.cxf.ws.transfer.Representation; + +/** + * Implementation of the ResourceTransformer for the XSL transformation. + */ +public class XSLTResourceTransformer implements ResourceTransformer { + + private static final Logger LOG = LogUtils.getL7dLogger(XSLTResourceTransformer.class); + + protected Templates templates; + + protected ResourceValidator validator; + + @Resource + private WebServiceContext context; + + public XSLTResourceTransformer(Source xsl) { + this(xsl, null); + } + + public XSLTResourceTransformer(Source xsl, ResourceValidator validator) { + this.validator = validator; + try { + templates = TransformerFactory.newInstance().newTemplates(xsl); + } catch (TransformerConfigurationException e) { + LOG.severe(e.getLocalizedMessage()); + throw new SoapFault("Internal error", getSoapVersion().getReceiver()); + } + } + + @Override + public ResourceValidator transform(Representation newRepresentation, Representation oldRepresentation) { + Document doc = DOMUtils.createDocument(); + Node representation = (Node) newRepresentation.getAny(); + Node importedNode = doc.importNode(representation, true); + doc.appendChild(importedNode); + Document result = XSLTUtils.transform(templates, doc); + newRepresentation.setAny(result.getDocumentElement()); + return validator; + } + + private SoapVersion getSoapVersion() { + WrappedMessageContext wmc = (WrappedMessageContext) context.getMessageContext(); + SoapMessage message = (SoapMessage) wmc.getWrappedMessage(); + return message.getVersion(); + } + +} http://git-wip-us.apache.org/repos/asf/cxf/blob/517ef67f/rt/ws/transfer/src/main/resources/handler-chains/reference-parameter-parsing.xml ---------------------------------------------------------------------- diff --git a/rt/ws/transfer/src/main/resources/handler-chains/reference-parameter-parsing.xml b/rt/ws/transfer/src/main/resources/handler-chains/reference-parameter-parsing.xml new file mode 100644 index 0000000..e1018f8 --- /dev/null +++ b/rt/ws/transfer/src/main/resources/handler-chains/reference-parameter-parsing.xml @@ -0,0 +1,27 @@ +<?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. +--> +<handler-chains xmlns="http://java.sun.com/xml/ns/javaee"> + <handler-chain> + <handler> + <handler-name>ReferenceParameterParsingHandler</handler-name> + <handler-class>org.apache.cxf.ws.transfer.shared.handlers.ReferenceParameterParsingHandler</handler-class> + </handler> + </handler-chain> +</handler-chains> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cxf/blob/517ef67f/rt/ws/transfer/src/main/resources/schemas/catalog-fragment.cat ---------------------------------------------------------------------- diff --git a/rt/ws/transfer/src/main/resources/schemas/catalog-fragment.cat b/rt/ws/transfer/src/main/resources/schemas/catalog-fragment.cat new file mode 100644 index 0000000..6eb029c --- /dev/null +++ b/rt/ws/transfer/src/main/resources/schemas/catalog-fragment.cat @@ -0,0 +1,21 @@ +-- + 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. +-- + +SYSTEM "http://www.w3.org/2011/03/ws-fra" "fragment.xsd" + http://git-wip-us.apache.org/repos/asf/cxf/blob/517ef67f/rt/ws/transfer/src/main/resources/schemas/catalog.cat ---------------------------------------------------------------------- diff --git a/rt/ws/transfer/src/main/resources/schemas/catalog.cat b/rt/ws/transfer/src/main/resources/schemas/catalog.cat new file mode 100644 index 0000000..22bc651 --- /dev/null +++ b/rt/ws/transfer/src/main/resources/schemas/catalog.cat @@ -0,0 +1,23 @@ +-- + 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. +-- + +SYSTEM "http://www.w3.org/2011/03/ws-tra" "transfer.xsd" +SYSTEM "http://www.w3.org/2005/08/addressing" "ws-addr.xsd" +SYSTEM "http://www.w3.org/2006/03/addressing/ws-addr.xsd" "ws-addr.xsd" + http://git-wip-us.apache.org/repos/asf/cxf/blob/517ef67f/rt/ws/transfer/src/main/resources/schemas/fragment.xsd ---------------------------------------------------------------------- diff --git a/rt/ws/transfer/src/main/resources/schemas/fragment.xsd b/rt/ws/transfer/src/main/resources/schemas/fragment.xsd new file mode 100644 index 0000000..519cb3a --- /dev/null +++ b/rt/ws/transfer/src/main/resources/schemas/fragment.xsd @@ -0,0 +1,87 @@ +<?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. +--> + +<xs:schema + targetNamespace='http://www.w3.org/2011/03/ws-fra' + xmlns:tns='http://www.w3.org/2011/03/ws-fra' + xmlns:xs='http://www.w3.org/2001/XMLSchema' + elementFormDefault='qualified' + blockDefault='#all' > + + <xs:complexType name='ExpressionType' mixed="true"> + <xs:sequence> + <xs:any namespace='##other' minOccurs='0' maxOccurs='unbounded'/> + </xs:sequence> + <xs:attribute name='Language' type='xs:anyURI' use='optional'/> + <xs:attribute name='Mode' type='xs:anyURI' use='optional'/> + <xs:anyAttribute namespace='##other' processContents='lax'/> + </xs:complexType> + <xs:element name='Expression' type='tns:ExpressionType'/> + + <xs:complexType name='ValueType' mixed="true"> + <xs:sequence> + <xs:any namespace='##other' minOccurs='0' maxOccurs='unbounded'/> + </xs:sequence> + <xs:anyAttribute namespace='##other' processContents='lax'/> + </xs:complexType> + <xs:element name='Value' type='tns:ValueType'/> + + <xs:element name='Fragment'> + <xs:complexType> + <xs:sequence> + <xs:element name='Expression' type='tns:ExpressionType'/> + <xs:element name='Value' type='tns:ValueType' minOccurs='0'/> + <xs:any namespace='##other' minOccurs='0' maxOccurs='unbounded'/> + </xs:sequence> + <xs:anyAttribute namespace='##other' processContents='lax'/> + </xs:complexType> + </xs:element> + + <!-- Policy --> + <xs:complexType name='URI'> + <xs:simpleContent> + <xs:extension base='xs:anyURI'> + <xs:anyAttribute namespace='##other' processContents='lax'/> + </xs:extension> + </xs:simpleContent> + </xs:complexType> + + <xs:element name='FragmentAssertion'> + <xs:complexType> + <xs:sequence> + <xs:element name='Language' minOccurs='0' maxOccurs='unbounded'> + <xs:complexType> + <xs:sequence> + <xs:any namespace='##other' processContents='lax' minOccurs='0' + maxOccurs='0'/> + </xs:sequence> + <xs:attribute name='URI' type='xs:anyURI' use='required' /> + <xs:anyAttribute namespace="##other" processContents='lax'/> + </xs:complexType> + </xs:element> + <xs:any namespace='##other' processContents='lax' minOccurs='0' + maxOccurs='unbounded'/> + </xs:sequence> + <xs:anyAttribute namespace='##other' processContents='lax' /> + </xs:complexType> + </xs:element> + +</xs:schema> http://git-wip-us.apache.org/repos/asf/cxf/blob/517ef67f/rt/ws/transfer/src/main/resources/schemas/transfer.xjb ---------------------------------------------------------------------- diff --git a/rt/ws/transfer/src/main/resources/schemas/transfer.xjb b/rt/ws/transfer/src/main/resources/schemas/transfer.xjb new file mode 100644 index 0000000..ea8d17e --- /dev/null +++ b/rt/ws/transfer/src/main/resources/schemas/transfer.xjb @@ -0,0 +1,37 @@ +<?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. +--> + +<bindings version="2.0" xmlns="http://java.sun.com/xml/ns/jaxb" + xmlns:xs="http://www.w3.org/2001/XMLSchema"> + + <bindings schemaLocation="http://www.w3.org/2006/03/addressing/ws-addr.xsd"> + <schemaBindings map="false"/> + <bindings node="//xs:complexType[@name='ReferenceParametersType']"> + <class ref="org.apache.cxf.ws.addressing.ReferenceParametersType"/> + </bindings> + <bindings node="//xs:complexType[@name='EndpointReferenceType']"> + <class ref="org.apache.cxf.ws.addressing.EndpointReferenceType"/> + </bindings> + <bindings node="//xs:complexType[@name='AttributedURIType']"> + <class ref="org.apache.cxf.ws.addressing.AttributedURIType"/> + </bindings> + </bindings> +</bindings> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cxf/blob/517ef67f/rt/ws/transfer/src/main/resources/schemas/transfer.xsd ---------------------------------------------------------------------- diff --git a/rt/ws/transfer/src/main/resources/schemas/transfer.xsd b/rt/ws/transfer/src/main/resources/schemas/transfer.xsd new file mode 100644 index 0000000..de5c48a --- /dev/null +++ b/rt/ws/transfer/src/main/resources/schemas/transfer.xsd @@ -0,0 +1,192 @@ +<?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. +--> + +<xs:schema + targetNamespace='http://www.w3.org/2011/03/ws-tra' + xmlns:tns='http://www.w3.org/2011/03/ws-tra' + xmlns:xs='http://www.w3.org/2001/XMLSchema' + xmlns:wsa='http://www.w3.org/2005/08/addressing' + elementFormDefault='qualified' + blockDefault='#all' > + + <xs:import + namespace='http://www.w3.org/2005/08/addressing' + schemaLocation='http://www.w3.org/2006/03/addressing/ws-addr.xsd' /> + + <xs:complexType name='Representation'> + <xs:sequence> + <xs:any minOccurs='0' processContents='lax'/> + </xs:sequence> + <xs:anyAttribute namespace='##other' processContents='lax'/> + </xs:complexType> + + <xs:element name='Get'> + <xs:complexType> + <xs:sequence> + <xs:any minOccurs='0' maxOccurs='unbounded' namespace='##other' processContents='lax' /> + </xs:sequence> + <xs:attribute name='Dialect' type='xs:anyURI' use='optional' /> + <xs:anyAttribute namespace='##other' processContents='lax' /> + </xs:complexType> + </xs:element> + + <xs:element name='GetResponse'> + <xs:complexType> + <xs:sequence> + <xs:element name='Representation' type='tns:Representation' minOccurs='0'/> + <xs:any minOccurs='1' maxOccurs='unbounded' namespace='##other' processContents='lax' /> + </xs:sequence> + <xs:anyAttribute namespace='##other' processContents='lax' /> + </xs:complexType> + </xs:element> + + <xs:element name='Put'> + <xs:complexType> + <xs:sequence> + <xs:element name='Representation' type='tns:Representation' minOccurs='0'/> + <xs:any minOccurs='1' maxOccurs='unbounded' namespace='##other' processContents='lax' /> + </xs:sequence> + <xs:attribute name='Dialect' type='xs:anyURI' use='optional' /> + <xs:anyAttribute namespace='##other' processContents='lax' /> + </xs:complexType> + </xs:element> + + <xs:element name='PutResponse'> + <xs:complexType> + <xs:sequence> + <xs:element name='Representation' type='tns:Representation' minOccurs='0'/> + <xs:any minOccurs='1' namespace='##other' processContents='lax' /> + </xs:sequence> + <xs:anyAttribute namespace='##other' processContents='lax' /> + </xs:complexType> + </xs:element> + + <xs:element name='Delete'> + <xs:complexType> + <xs:sequence> + <xs:any minOccurs='0' maxOccurs='unbounded' namespace='##other' processContents='lax' /> + </xs:sequence> + <xs:attribute name='Dialect' type='xs:anyURI' use='optional' /> + <xs:anyAttribute namespace='##other' processContents='lax' /> + </xs:complexType> + </xs:element> + + <xs:element name='DeleteResponse'> + <xs:complexType> + <xs:sequence> + <xs:any minOccurs='0' namespace='##other' processContents='lax' /> + </xs:sequence> + <xs:anyAttribute namespace='##other' processContents='lax' /> + </xs:complexType> + </xs:element> + + <xs:element name='Create'> + <xs:complexType> + <xs:sequence> + <xs:element name='Representation' type='tns:Representation' minOccurs='0'/> + <xs:any minOccurs='0' maxOccurs='unbounded' namespace='##other' processContents='lax' /> + </xs:sequence> + <xs:attribute name='Dialect' type='xs:anyURI' use='optional' /> + <xs:anyAttribute namespace='##other' processContents='lax' /> + </xs:complexType> + </xs:element> + + <xs:element name='CreateResponse'> + <xs:complexType> + <xs:sequence> + <xs:element name='ResourceCreated' type='wsa:EndpointReferenceType' /> + <xs:element name='Representation' type='tns:Representation' minOccurs='0'/> + <xs:any minOccurs='0' namespace='##other' processContents='lax' /> + </xs:sequence> + <xs:anyAttribute namespace='##other' processContents='lax' /> + </xs:complexType> + </xs:element> + + <!-- Policy --> + <xs:complexType name='URI'> + <xs:simpleContent> + <xs:extension base='xs:anyURI'> + <xs:anyAttribute namespace='##other' processContents='lax'/> + </xs:extension> + </xs:simpleContent> + </xs:complexType> + + <xs:complexType name='QName'> + <xs:simpleContent> + <xs:extension base='xs:QName'> + <xs:anyAttribute namespace='##other' processContents='lax'/> + </xs:extension> + </xs:simpleContent> + </xs:complexType> + + <xs:complexType name='Empty'> + <xs:sequence/> + <xs:anyAttribute namespace='##other' processContents='lax'/> + </xs:complexType> + + <xs:element name='TransferResource'> + <xs:complexType> + <xs:sequence> + <xs:element name='PutOperationSupported' type='tns:Empty' + minOccurs='0'/> + <xs:element name='DeleteOperationSupported' type='tns:Empty' + minOccurs='0'/> + <xs:element name='FaultOnPutDenied' type='tns:Empty' minOccurs='0'/> + <xs:element name='Dialect' minOccurs='0' maxOccurs='unbounded'> + <xs:complexType> + <xs:sequence> + <xs:any namespace='##other' processContents='lax' minOccurs='0' + maxOccurs='0'/> + </xs:sequence> + <xs:attribute name='URI' type='xs:anyURI' use='required' /> + <xs:anyAttribute namespace="##other" processContents='lax'/> + </xs:complexType> + </xs:element> + <xs:element name='Resource' type='tns:QName' minOccurs='0'/> + <xs:any namespace='##other' processContents='lax' minOccurs='0' + maxOccurs='unbounded'/> + </xs:sequence> + <xs:anyAttribute namespace='##other' processContents='lax' /> + </xs:complexType> + </xs:element> + + <xs:element name='TransferResourceFactory'> + <xs:complexType> + <xs:sequence> + <xs:element name='Resource' type='tns:QName' minOccurs='0'/> + <xs:element name='Dialect' minOccurs='0' maxOccurs='unbounded'> + <xs:complexType> + <xs:sequence> + <xs:any namespace='##other' processContents='lax' minOccurs='0' + maxOccurs='0'/> + </xs:sequence> + <xs:attribute name='URI' type='xs:anyURI' use='required' /> + <xs:anyAttribute namespace="##other" processContents='lax'/> + </xs:complexType> + </xs:element> + <xs:any namespace='##other' processContents='lax' minOccurs='0' + maxOccurs='unbounded'/> + </xs:sequence> + <xs:anyAttribute namespace='##other' processContents='lax' /> + </xs:complexType> + </xs:element> + +</xs:schema> http://git-wip-us.apache.org/repos/asf/cxf/blob/517ef67f/rt/ws/transfer/src/main/resources/schemas/ws-addr.xsd ---------------------------------------------------------------------- diff --git a/rt/ws/transfer/src/main/resources/schemas/ws-addr.xsd b/rt/ws/transfer/src/main/resources/schemas/ws-addr.xsd new file mode 100644 index 0000000..05ca1bc --- /dev/null +++ b/rt/ws/transfer/src/main/resources/schemas/ws-addr.xsd @@ -0,0 +1,141 @@ +<?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. +--> + +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://www.w3.org/2005/08/addressing" targetNamespace="http://www.w3.org/2005/08/addressing" blockDefault="#all" elementFormDefault="qualified" finalDefault="" attributeFormDefault="unqualified"> + + <!-- Constructs from the WS-Addressing Core --> + + <xs:element name="EndpointReference" type="tns:EndpointReferenceType"/> + <xs:complexType name="EndpointReferenceType" mixed="false"> + <xs:sequence> + <xs:element name="Address" type="tns:AttributedURIType"/> + <xs:element ref="tns:ReferenceParameters" minOccurs="0"/> + <xs:element ref="tns:Metadata" minOccurs="0"/> + <xs:any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/> + </xs:sequence> + <xs:anyAttribute namespace="##other" processContents="lax"/> + </xs:complexType> + + <xs:element name="ReferenceParameters" type="tns:ReferenceParametersType"/> + <xs:complexType name="ReferenceParametersType" mixed="false"> + <xs:sequence> + <xs:any namespace="##any" processContents="lax" minOccurs="0" maxOccurs="unbounded"/> + </xs:sequence> + <xs:anyAttribute namespace="##other" processContents="lax"/> + </xs:complexType> + + <xs:element name="Metadata" type="tns:MetadataType"/> + <xs:complexType name="MetadataType" mixed="false"> + <xs:sequence> + <xs:any namespace="##any" processContents="lax" minOccurs="0" maxOccurs="unbounded"/> + </xs:sequence> + <xs:anyAttribute namespace="##other" processContents="lax"/> + </xs:complexType> + + <xs:element name="MessageID" type="tns:AttributedURIType"/> + <xs:element name="RelatesTo" type="tns:RelatesToType"/> + <xs:complexType name="RelatesToType" mixed="false"> + <xs:simpleContent> + <xs:extension base="xs:anyURI"> + <xs:attribute name="RelationshipType" type="tns:RelationshipTypeOpenEnum" use="optional" default="http://www.w3.org/2005/08/addressing/reply"/> + <xs:anyAttribute namespace="##other" processContents="lax"/> + </xs:extension> + </xs:simpleContent> + </xs:complexType> + + <xs:simpleType name="RelationshipTypeOpenEnum"> + <xs:union memberTypes="tns:RelationshipType xs:anyURI"/> + </xs:simpleType> + + <xs:simpleType name="RelationshipType"> + <xs:restriction base="xs:anyURI"> + <xs:enumeration value="http://www.w3.org/2005/08/addressing/reply"/> + </xs:restriction> + </xs:simpleType> + + <xs:element name="ReplyTo" type="tns:EndpointReferenceType"/> + <xs:element name="From" type="tns:EndpointReferenceType"/> + <xs:element name="FaultTo" type="tns:EndpointReferenceType"/> + <xs:element name="To" type="tns:AttributedURIType"/> + <xs:element name="Action" type="tns:AttributedURIType"/> + + <xs:complexType name="AttributedURIType" mixed="false"> + <xs:simpleContent> + <xs:extension base="xs:anyURI"> + <xs:anyAttribute namespace="##other" processContents="lax"/> + </xs:extension> + </xs:simpleContent> + </xs:complexType> + + <!-- Constructs from the WS-Addressing SOAP binding --> + + <xs:attribute name="IsReferenceParameter" type="xs:boolean"/> + + <xs:simpleType name="FaultCodesOpenEnumType"> + <xs:union memberTypes="tns:FaultCodesType xs:QName"/> + </xs:simpleType> + + <xs:simpleType name="FaultCodesType"> + <xs:restriction base="xs:QName"> + <xs:enumeration value="tns:InvalidAddressingHeader"/> + <xs:enumeration value="tns:InvalidAddress"/> + <xs:enumeration value="tns:InvalidEPR"/> + <xs:enumeration value="tns:InvalidCardinality"/> + <xs:enumeration value="tns:MissingAddressInEPR"/> + <xs:enumeration value="tns:DuplicateMessageID"/> + <xs:enumeration value="tns:ActionMismatch"/> + <xs:enumeration value="tns:MessageAddressingHeaderRequired"/> + <xs:enumeration value="tns:DestinationUnreachable"/> + <xs:enumeration value="tns:ActionNotSupported"/> + <xs:enumeration value="tns:EndpointUnavailable"/> + </xs:restriction> + </xs:simpleType> + + <xs:element name="RetryAfter" type="tns:AttributedUnsignedLongType"/> + <xs:complexType name="AttributedUnsignedLongType" mixed="false"> + <xs:simpleContent> + <xs:extension base="xs:unsignedLong"> + <xs:anyAttribute namespace="##other" processContents="lax"/> + </xs:extension> + </xs:simpleContent> + </xs:complexType> + + <xs:element name="ProblemHeaderQName" type="tns:AttributedQNameType"/> + <xs:complexType name="AttributedQNameType" mixed="false"> + <xs:simpleContent> + <xs:extension base="xs:QName"> + <xs:anyAttribute namespace="##other" processContents="lax"/> + </xs:extension> + </xs:simpleContent> + </xs:complexType> + + <xs:element name="ProblemIRI" type="tns:AttributedURIType"/> + + <xs:element name="ProblemAction" type="tns:ProblemActionType"/> + <xs:complexType name="ProblemActionType" mixed="false"> + <xs:sequence> + <xs:element ref="tns:Action" minOccurs="0"/> + <xs:element name="SoapAction" minOccurs="0" type="xs:anyURI"/> + </xs:sequence> + <xs:anyAttribute namespace="##other" processContents="lax"/> + </xs:complexType> + +</xs:schema>
