use of org.apache.cxf.ws.addressing.ReferenceParametersType in project cxf by apache.
the class ResourceLocal method put.
@Override
public PutResponse put(Put body) {
// Getting reference paramaters
AddressingProperties addrProps = (AddressingProperties) ((WrappedMessageContext) context.getMessageContext()).getWrappedMessage().getContextualProperty(JAXWSAConstants.ADDRESSING_PROPERTIES_INBOUND);
ReferenceParametersType refParams = addrProps.getToEndpointReference().getReferenceParameters();
// Getting representation from the ResourceManager
Representation storedRepresentation = manager.get(refParams);
// Getting representation from the incoming SOAP message. This representation will be stored.
Representation putRepresentation = body.getRepresentation();
// Dialect processing
if (body.getDialect() != null && !body.getDialect().isEmpty()) {
if (dialects.containsKey(body.getDialect())) {
Dialect dialect = dialects.get(body.getDialect());
putRepresentation = dialect.processPut(body, storedRepresentation);
} else {
throw new UnknownDialect();
}
}
ValidAndTransformHelper.validationAndTransformation(resourceTypeIdentifiers, putRepresentation, storedRepresentation);
manager.put(refParams, putRepresentation);
PutResponse response = new PutResponse();
response.setRepresentation(putRepresentation);
return response;
}
use of org.apache.cxf.ws.addressing.ReferenceParametersType in project cxf by apache.
the class ResourceFactoryImpl method createLocally.
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;
}
use of org.apache.cxf.ws.addressing.ReferenceParametersType in project cxf by apache.
the class FragmentGetQNameTest method getTest.
@Test
public void getTest() throws XMLStreamException {
String content = "<root><a><b>Text</b></a></root>";
ResourceManager resourceManager = new MemoryResourceManager();
ReferenceParametersType refParams = resourceManager.create(getRepresentation(content));
Server resource = createLocalResource(resourceManager);
Resource client = createClient(refParams);
ObjectFactory objectFactory = new ObjectFactory();
Get request = new Get();
request.setDialect(FragmentDialectConstants.FRAGMENT_2011_03_IRI);
ExpressionType expression = new ExpressionType();
expression.setLanguage(FragmentDialectConstants.QNAME_LANGUAGE_IRI);
expression.getContent().add("a");
request.getAny().add(objectFactory.createExpression(expression));
GetResponse response = client.get(request);
ValueType value = getValue(response);
Assert.assertEquals(1, value.getContent().size());
Assert.assertEquals("a", ((Element) value.getContent().get(0)).getLocalName());
resource.destroy();
}
use of org.apache.cxf.ws.addressing.ReferenceParametersType in project cxf by apache.
the class FragmentGetQNameTest method getWrongQNameTest.
@Test(expected = SOAPFaultException.class)
public void getWrongQNameTest() throws XMLStreamException {
String content = "<root><a><b>Text1</b><b>Text2</b><b>Text3</b></a></root>";
ResourceManager resourceManager = new MemoryResourceManager();
ReferenceParametersType refParams = resourceManager.create(getRepresentation(content));
createLocalResource(resourceManager);
Resource client = createClient(refParams);
ObjectFactory objectFactory = new ObjectFactory();
Get request = new Get();
request.setDialect(FragmentDialectConstants.FRAGMENT_2011_03_IRI);
ExpressionType expression = new ExpressionType();
expression.setLanguage(FragmentDialectConstants.QNAME_LANGUAGE_IRI);
expression.getContent().add("//b");
request.getAny().add(objectFactory.createExpression(expression));
client.get(request);
}
use of org.apache.cxf.ws.addressing.ReferenceParametersType in project cxf by apache.
the class FragmentGetQNameTest method getWithNamespaceTest.
@Test
public void getWithNamespaceTest() throws XMLStreamException {
String content = "<ns:root xmlns:ns=\"www.example.org\"><ns:a><ns:b>Text</ns:b></ns:a></ns:root>";
ResourceManager resourceManager = new MemoryResourceManager();
ReferenceParametersType refParams = resourceManager.create(getRepresentation(content));
Server resource = createLocalResource(resourceManager);
Resource client = createClient(refParams);
ObjectFactory objectFactory = new ObjectFactory();
Get request = new Get();
request.setDialect(FragmentDialectConstants.FRAGMENT_2011_03_IRI);
ExpressionType expression = new ExpressionType();
expression.setLanguage(FragmentDialectConstants.QNAME_LANGUAGE_IRI);
expression.getContent().add("ns:a");
request.getAny().add(objectFactory.createExpression(expression));
GetResponse response = client.get(request);
ValueType value = getValue(response);
Assert.assertEquals(1, value.getContent().size());
Assert.assertEquals("a", ((Element) value.getContent().get(0)).getLocalName());
Assert.assertEquals("www.example.org", ((Element) value.getContent().get(0)).getNamespaceURI());
resource.destroy();
}
Aggregations