Search in sources :

Example 11 with Representation

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;
}
Also used : Representation(org.apache.cxf.ws.transfer.Representation) Document(org.w3c.dom.Document)

Example 12 with 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;
}
Also used : Node(org.w3c.dom.Node) Representation(org.apache.cxf.ws.transfer.Representation) InvalidRepresentation(org.apache.cxf.ws.transfer.shared.faults.InvalidRepresentation) Document(org.w3c.dom.Document) InvalidExpression(org.apache.cxf.ws.transfer.dialect.fragment.faults.InvalidExpression)

Example 13 with 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;
}
Also used : UnknownDialect(org.apache.cxf.ws.transfer.shared.faults.UnknownDialect) WrappedMessageContext(org.apache.cxf.jaxws.context.WrappedMessageContext) FragmentDialect(org.apache.cxf.ws.transfer.dialect.fragment.FragmentDialect) UnknownDialect(org.apache.cxf.ws.transfer.shared.faults.UnknownDialect) Dialect(org.apache.cxf.ws.transfer.dialect.Dialect) AddressingProperties(org.apache.cxf.ws.addressing.AddressingProperties) ReferenceParametersType(org.apache.cxf.ws.addressing.ReferenceParametersType) Representation(org.apache.cxf.ws.transfer.Representation) GetResponse(org.apache.cxf.ws.transfer.GetResponse)

Example 14 with Representation

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;
}
Also used : EndpointReferenceType(org.apache.cxf.ws.addressing.EndpointReferenceType) CreateResponse(org.apache.cxf.ws.transfer.CreateResponse) Representation(org.apache.cxf.ws.transfer.Representation) ReferenceParametersType(org.apache.cxf.ws.addressing.ReferenceParametersType)

Example 15 with Representation

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);
}
Also used : UnknownDialect(org.apache.cxf.ws.transfer.shared.faults.UnknownDialect) UnknownDialect(org.apache.cxf.ws.transfer.shared.faults.UnknownDialect) Dialect(org.apache.cxf.ws.transfer.dialect.Dialect) Representation(org.apache.cxf.ws.transfer.Representation) ResourceReference(org.apache.cxf.ws.transfer.resourcefactory.resolver.ResourceReference)

Aggregations

Representation (org.apache.cxf.ws.transfer.Representation)48 Test (org.junit.Test)29 Document (org.w3c.dom.Document)25 ReferenceParametersType (org.apache.cxf.ws.addressing.ReferenceParametersType)21 Element (org.w3c.dom.Element)15 Create (org.apache.cxf.ws.transfer.Create)14 ResourceFactory (org.apache.cxf.ws.transfer.resourcefactory.ResourceFactory)14 CreateResponse (org.apache.cxf.ws.transfer.CreateResponse)12 Resource (org.apache.cxf.ws.transfer.resource.Resource)11 Put (org.apache.cxf.ws.transfer.Put)10 Server (org.apache.cxf.endpoint.Server)9 ResourceManager (org.apache.cxf.ws.transfer.manager.ResourceManager)9 PutResponse (org.apache.cxf.ws.transfer.PutResponse)7 MemoryResourceManager (org.apache.cxf.ws.transfer.manager.MemoryResourceManager)7 ExpressionType (org.apache.cxf.ws.transfer.dialect.fragment.ExpressionType)5 Fragment (org.apache.cxf.ws.transfer.dialect.fragment.Fragment)5 ValueType (org.apache.cxf.ws.transfer.dialect.fragment.ValueType)5 InvalidExpression (org.apache.cxf.ws.transfer.dialect.fragment.faults.InvalidExpression)5 InvalidRepresentation (org.apache.cxf.ws.transfer.shared.faults.InvalidRepresentation)5 Node (org.w3c.dom.Node)5