use of org.apache.cxf.ws.transfer.Representation in project cxf by apache.
the class XSLTResourceTransformerTest method loadRepresentation.
private Representation loadRepresentation(InputStream input) throws XMLStreamException {
Document doc = StaxUtils.read(input);
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 FragmentDialect method modifyRepresentationModeAdd.
/**
* Process Put requests for Add mode.
* @param value Value defined in the Value element.
* @return Representation element, which is returned as response.
*/
private Representation modifyRepresentationModeAdd(List<Node> nodeList, ValueType value) {
if (nodeList.isEmpty()) {
throw new InvalidExpression();
}
Node firstNode = nodeList.get(0);
Document ownerDocument = firstNode.getOwnerDocument();
// if firstNode.getOwnerDocument == null the firstNode is ownerDocument
ownerDocument = ownerDocument == null ? (Document) firstNode : ownerDocument;
for (Node node : nodeList) {
addNode(ownerDocument, node, null, value);
}
Representation representation = new Representation();
representation.setAny(ownerDocument.getDocumentElement());
return representation;
}
use of org.apache.cxf.ws.transfer.Representation in project cxf by apache.
the class ResourceLocal method get.
@Override
public GetResponse get(Get body) {
// Getting reference paramaters
AddressingProperties addrProps = (AddressingProperties) ((WrappedMessageContext) context.getMessageContext()).getWrappedMessage().getContextualProperty(JAXWSAConstants.ADDRESSING_PROPERTIES_INBOUND);
ReferenceParametersType refParams = addrProps.getToEndpointReference().getReferenceParameters();
GetResponse response = new GetResponse();
// Getting representation from the ResourceManager
Representation representation = manager.get(refParams);
// Dialect processing
if (body.getDialect() != null && !body.getDialect().isEmpty()) {
if (dialects.containsKey(body.getDialect())) {
Dialect dialect = dialects.get(body.getDialect());
// Send fragment of resource instead it's representation.
response.getAny().add(dialect.processGet(body, representation));
} else {
throw new UnknownDialect();
}
} else {
// Send representation obtained from ResourceManager.
response.setRepresentation(representation);
}
return response;
}
use of org.apache.cxf.ws.transfer.Representation in project cxf by apache.
the class ResourceRemote method create.
@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;
}
use of org.apache.cxf.ws.transfer.Representation in project cxf by apache.
the class ResourceFactoryImpl method create.
@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);
}
return createRemotely(body, resourceReference);
}
Aggregations