Search in sources :

Example 31 with ReferenceParametersType

use of org.apache.cxf.ws.addressing.ReferenceParametersType in project cxf by apache.

the class SubscriptionManagerImpl method grantSubscriptionManagerReference.

protected void grantSubscriptionManagerReference(SubscriptionTicket ticket, SubscriptionTicketGrantingResponse response) {
    EndpointReferenceType subscriptionManagerReference = new EndpointReferenceType();
    subscriptionManagerReference.setAddress(getSubscriptionManagerAddress());
    // generate a ID for this subscription
    UUID uuid = UUID.randomUUID();
    JAXBElement<String> idqn = new JAXBElement<String>(new QName(subscriptionIdNamespace, subscriptionIdElementName), String.class, uuid.toString());
    subscriptionManagerReference.setReferenceParameters(new ReferenceParametersType());
    subscriptionManagerReference.getReferenceParameters().getAny().add(idqn);
    ticket.setUuid(uuid);
    response.setSubscriptionManagerReference(subscriptionManagerReference);
    response.setUUID(uuid);
}
Also used : EndpointReferenceType(org.apache.cxf.ws.addressing.EndpointReferenceType) QName(javax.xml.namespace.QName) ReferenceParametersType(org.apache.cxf.ws.addressing.ReferenceParametersType) JAXBElement(javax.xml.bind.JAXBElement) UUID(java.util.UUID)

Example 32 with ReferenceParametersType

use of org.apache.cxf.ws.addressing.ReferenceParametersType in project cxf by apache.

the class MemoryResourceManager method create.

@Override
public ReferenceParametersType create(Representation initRepresentation) {
    // Store xmlResource
    String uuid = UUID.randomUUID().toString();
    Element representationEl = (Element) initRepresentation.getAny();
    if (representationEl == null) {
        storage.put(uuid, "");
    } else {
        storage.put(uuid, StaxUtils.toString(representationEl));
    }
    Element uuidEl = DOMUtils.getEmptyDocument().createElementNS(REF_NAMESPACE, REF_LOCAL_NAME);
    uuidEl.setTextContent(uuid);
    // Create referenceParameter
    ReferenceParametersType refParam = new ReferenceParametersType();
    refParam.getAny().add(uuidEl);
    return refParam;
}
Also used : JAXBElement(javax.xml.bind.JAXBElement) Element(org.w3c.dom.Element) ReferenceParametersType(org.apache.cxf.ws.addressing.ReferenceParametersType)

Example 33 with ReferenceParametersType

use of org.apache.cxf.ws.addressing.ReferenceParametersType 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 34 with ReferenceParametersType

use of org.apache.cxf.ws.addressing.ReferenceParametersType 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 35 with ReferenceParametersType

use of org.apache.cxf.ws.addressing.ReferenceParametersType in project cxf by apache.

the class FragmentGetQNameTest method getMoreValuesTest.

@Test
public void getMoreValuesTest() throws XMLStreamException {
    String content = "<root><b>Text1</b><b>Text2</b><b>Text3</b></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("b");
    request.getAny().add(objectFactory.createExpression(expression));
    GetResponse response = client.get(request);
    ValueType value = getValue(response);
    Assert.assertEquals(3, value.getContent().size());
    Assert.assertEquals("b", ((Element) value.getContent().get(0)).getLocalName());
    Assert.assertEquals("b", ((Element) value.getContent().get(1)).getLocalName());
    Assert.assertEquals("b", ((Element) value.getContent().get(2)).getLocalName());
    resource.destroy();
}
Also used : Server(org.apache.cxf.endpoint.Server) ObjectFactory(org.apache.cxf.ws.transfer.dialect.fragment.ObjectFactory) ValueType(org.apache.cxf.ws.transfer.dialect.fragment.ValueType) Get(org.apache.cxf.ws.transfer.Get) Resource(org.apache.cxf.ws.transfer.resource.Resource) ReferenceParametersType(org.apache.cxf.ws.addressing.ReferenceParametersType) MemoryResourceManager(org.apache.cxf.ws.transfer.manager.MemoryResourceManager) ResourceManager(org.apache.cxf.ws.transfer.manager.ResourceManager) MemoryResourceManager(org.apache.cxf.ws.transfer.manager.MemoryResourceManager) ExpressionType(org.apache.cxf.ws.transfer.dialect.fragment.ExpressionType) GetResponse(org.apache.cxf.ws.transfer.GetResponse) Test(org.junit.Test)

Aggregations

ReferenceParametersType (org.apache.cxf.ws.addressing.ReferenceParametersType)76 Test (org.junit.Test)65 Server (org.apache.cxf.endpoint.Server)54 ResourceManager (org.apache.cxf.ws.transfer.manager.ResourceManager)53 MemoryResourceManager (org.apache.cxf.ws.transfer.manager.MemoryResourceManager)51 Resource (org.apache.cxf.ws.transfer.resource.Resource)51 Element (org.w3c.dom.Element)50 ExpressionType (org.apache.cxf.ws.transfer.dialect.fragment.ExpressionType)48 ValueType (org.apache.cxf.ws.transfer.dialect.fragment.ValueType)44 Put (org.apache.cxf.ws.transfer.Put)33 Fragment (org.apache.cxf.ws.transfer.dialect.fragment.Fragment)32 PutResponse (org.apache.cxf.ws.transfer.PutResponse)26 Representation (org.apache.cxf.ws.transfer.Representation)21 Get (org.apache.cxf.ws.transfer.Get)17 GetResponse (org.apache.cxf.ws.transfer.GetResponse)17 ObjectFactory (org.apache.cxf.ws.transfer.dialect.fragment.ObjectFactory)16 JAXBElement (javax.xml.bind.JAXBElement)8 EndpointReferenceType (org.apache.cxf.ws.addressing.EndpointReferenceType)8 QName (javax.xml.namespace.QName)4 CreateResponse (org.apache.cxf.ws.transfer.CreateResponse)4