Search in sources :

Example 46 with Representation

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;
}
Also used : UnknownResource(org.apache.cxf.ws.transfer.shared.faults.UnknownResource) SoapFault(org.apache.cxf.binding.soap.SoapFault) XMLStreamException(javax.xml.stream.XMLStreamException) StringReader(java.io.StringReader) Representation(org.apache.cxf.ws.transfer.Representation) Document(org.w3c.dom.Document)

Example 47 with 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;
}
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) PutResponse(org.apache.cxf.ws.transfer.PutResponse)

Example 48 with Representation

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

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