use of org.apache.cxf.ws.transfer.Representation in project cxf by apache.
the class MemoryResourceManager method get.
@Override
public Representation get(ReferenceParametersType ref) {
String uuid = getUUID(ref);
if (!storage.containsKey(uuid)) {
throw new UnknownResource();
}
String resource = storage.get(uuid);
if (resource.isEmpty()) {
return new Representation();
}
Document doc = null;
try {
doc = StaxUtils.read(new StringReader(storage.get(uuid)));
} catch (XMLStreamException e) {
LOG.severe(e.getLocalizedMessage());
throw new SoapFault("Internal Error", getSoapVersion().getReceiver());
}
Representation representation = new Representation();
representation.setAny(doc.getDocumentElement());
return representation;
}
use of org.apache.cxf.ws.transfer.Representation 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.transfer.Representation 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;
}
Aggregations