Search in sources :

Example 1 with ServiceLocatorFault

use of org.talend.services.esb.locator.v1.ServiceLocatorFault in project tesb-rt-se by Talend.

the class LocatorSoapServiceImpl method updateTimetolive.

/**
 * @see ServiceLocator
 */
@Override
public void updateTimetolive(QName serviceName, String endpointURL, int timetolive) throws ServiceLocatorFault, InterruptedExceptionFault {
    if (LOG.isLoggable(Level.FINE)) {
        LOG.fine("Updating expiring time to happen in " + timetolive + " seconds on endpoint " + endpointURL + " for service " + serviceName + "...");
    }
    try {
        initLocator();
        locatorClient.updateTimetolive(serviceName, endpointURL, timetolive);
    } catch (ServiceLocatorException e) {
        ServiceLocatorFaultDetail serviceFaultDetail = new ServiceLocatorFaultDetail();
        serviceFaultDetail.setLocatorFaultDetail(serviceName.toString() + "throws ServiceLocatorFault");
        throw new ServiceLocatorFault(e.getMessage(), serviceFaultDetail);
    } catch (InterruptedException e) {
        InterruptionFaultDetail interruptionFaultDetail = new InterruptionFaultDetail();
        interruptionFaultDetail.setInterruptionDetail(serviceName.toString() + "throws InterruptionFault");
        throw new InterruptedExceptionFault(e.getMessage(), interruptionFaultDetail);
    }
}
Also used : InterruptionFaultDetail(org.talend.schemas.esb.locator._2011._11.InterruptionFaultDetail) ServiceLocatorException(org.talend.esb.servicelocator.client.ServiceLocatorException) ServiceLocatorFault(org.talend.services.esb.locator.v1.ServiceLocatorFault) InterruptedExceptionFault(org.talend.services.esb.locator.v1.InterruptedExceptionFault) ServiceLocatorFaultDetail(org.talend.schemas.esb.locator._2011._11.ServiceLocatorFaultDetail)

Example 2 with ServiceLocatorFault

use of org.talend.services.esb.locator.v1.ServiceLocatorFault in project tesb-rt-se by Talend.

the class LocatorSoapServiceImpl method buildEndpoint.

/**
 * Build Endpoint Reference for giving service name and address
 *
 * @param serviceName
 * @param adress
 * @return
 */
private W3CEndpointReference buildEndpoint(QName serviceName, String adress) throws ServiceLocatorFault, InterruptedExceptionFault {
    W3CEndpointReferenceBuilder builder = new W3CEndpointReferenceBuilder();
    // builder.serviceName(serviceName);
    builder.address(adress);
    SLEndpoint endpoint = null;
    try {
        endpoint = locatorClient.getEndpoint(serviceName, adress);
    } catch (ServiceLocatorException e) {
        ServiceLocatorFaultDetail serviceFaultDetail = new ServiceLocatorFaultDetail();
        serviceFaultDetail.setLocatorFaultDetail(serviceName.toString() + "throws ServiceLocatorFault");
        throw new ServiceLocatorFault(e.getMessage(), serviceFaultDetail);
    } catch (InterruptedException e) {
        InterruptionFaultDetail interruptionFaultDetail = new InterruptionFaultDetail();
        interruptionFaultDetail.setInterruptionDetail(serviceName.toString() + "throws InterruptionFault");
        throw new InterruptedExceptionFault(e.getMessage(), interruptionFaultDetail);
    }
    if (endpoint != null) {
        SLProperties properties = endpoint.getProperties();
        if (properties != null && !properties.getPropertyNames().isEmpty()) {
            EndpointTransformerImpl transformer = new EndpointTransformerImpl();
            DOMResult result = new DOMResult();
            transformer.writePropertiesTo(properties, result);
            Document docResult = (Document) result.getNode();
            builder.metadata(docResult.getDocumentElement());
        }
    }
    return builder.build();
}
Also used : SLProperties(org.talend.esb.servicelocator.client.SLProperties) W3CEndpointReferenceBuilder(javax.xml.ws.wsaddressing.W3CEndpointReferenceBuilder) EndpointTransformerImpl(org.talend.esb.servicelocator.client.internal.EndpointTransformerImpl) DOMResult(javax.xml.transform.dom.DOMResult) InterruptionFaultDetail(org.talend.schemas.esb.locator._2011._11.InterruptionFaultDetail) ServiceLocatorException(org.talend.esb.servicelocator.client.ServiceLocatorException) ServiceLocatorFault(org.talend.services.esb.locator.v1.ServiceLocatorFault) SLEndpoint(org.talend.esb.servicelocator.client.SLEndpoint) Document(org.w3c.dom.Document) InterruptedExceptionFault(org.talend.services.esb.locator.v1.InterruptedExceptionFault) ServiceLocatorFaultDetail(org.talend.schemas.esb.locator._2011._11.ServiceLocatorFaultDetail)

Example 3 with ServiceLocatorFault

use of org.talend.services.esb.locator.v1.ServiceLocatorFault in project tesb-rt-se by Talend.

the class LocatorSoapServiceImpl method lookupEndpoint.

/**
 * For the given service return endpoint reference randomly selected from
 * list of endpoints currently registered at the service locator server.
 *
 * @param serviceName
 *            the name of the service for which to get the endpoints, must
 *            not be <code>null</code>
 * @return endpoint references or <code>null</code>
 */
W3CEndpointReference lookupEndpoint(QName serviceName, MatcherDataType matcherData) throws ServiceLocatorFault, InterruptedExceptionFault {
    List<String> names = null;
    String adress;
    try {
        initLocator();
        SLPropertiesMatcher matcher = createMatcher(matcherData);
        if (matcher == null) {
            names = locatorClient.lookup(serviceName);
        } else {
            names = locatorClient.lookup(serviceName, matcher);
        }
    } catch (ServiceLocatorException e) {
        ServiceLocatorFaultDetail serviceFaultDetail = new ServiceLocatorFaultDetail();
        serviceFaultDetail.setLocatorFaultDetail(serviceName.toString() + "throws ServiceLocatorFault");
        throw new ServiceLocatorFault(e.getMessage(), serviceFaultDetail);
    } catch (InterruptedException e) {
        InterruptionFaultDetail interruptionFaultDetail = new InterruptionFaultDetail();
        interruptionFaultDetail.setInterruptionDetail(serviceName.toString() + "throws InterruptionFault");
        throw new InterruptedExceptionFault(e.getMessage(), interruptionFaultDetail);
    }
    if (names != null && !names.isEmpty()) {
        names = getRotatedList(names);
        adress = names.get(0);
    } else {
        if (LOG.isLoggable(Level.WARNING)) {
            LOG.log(Level.WARNING, "lookup Endpoint for " + serviceName + " failed, service is not known.");
        }
        ServiceLocatorFaultDetail serviceFaultDetail = new ServiceLocatorFaultDetail();
        serviceFaultDetail.setLocatorFaultDetail("lookup Endpoint for " + serviceName + " failed, service is not known.");
        throw new ServiceLocatorFault("Can not find Endpoint", serviceFaultDetail);
    }
    return buildEndpoint(serviceName, adress);
}
Also used : InterruptionFaultDetail(org.talend.schemas.esb.locator._2011._11.InterruptionFaultDetail) ServiceLocatorException(org.talend.esb.servicelocator.client.ServiceLocatorException) SLPropertiesMatcher(org.talend.esb.servicelocator.client.SLPropertiesMatcher) ServiceLocatorFault(org.talend.services.esb.locator.v1.ServiceLocatorFault) InterruptedExceptionFault(org.talend.services.esb.locator.v1.InterruptedExceptionFault) ServiceLocatorFaultDetail(org.talend.schemas.esb.locator._2011._11.ServiceLocatorFaultDetail)

Example 4 with ServiceLocatorFault

use of org.talend.services.esb.locator.v1.ServiceLocatorFault in project tesb-rt-se by Talend.

the class LocatorSoapServiceTest method updateEndpointExpiringTimeMissingEndpoint.

@Test
public void updateEndpointExpiringTimeMissingEndpoint() throws Exception {
    final int ttl = 95;
    sl.updateTimetolive(SERVICE_NAME, ENDPOINTURL, ttl);
    expectLastCall().andThrow(new EndpointNotFoundException());
    replay(sl);
    try {
        lps.updateTimetolive(SERVICE_NAME, ENDPOINTURL, ttl);
        fail();
    } catch (ServiceLocatorFault e) {
    // pass
    }
    verify(sl);
}
Also used : EndpointNotFoundException(org.talend.esb.servicelocator.client.EndpointNotFoundException) ServiceLocatorFault(org.talend.services.esb.locator.v1.ServiceLocatorFault) Endpoint(org.talend.esb.servicelocator.client.Endpoint) SLEndpoint(org.talend.esb.servicelocator.client.SLEndpoint) Test(org.junit.Test)

Example 5 with ServiceLocatorFault

use of org.talend.services.esb.locator.v1.ServiceLocatorFault in project tesb-rt-se by Talend.

the class LocatorSoapServiceTest method updateEndpointExpiringTimeWrongTime.

@Test
public void updateEndpointExpiringTimeWrongTime() throws Exception {
    final int ttl = 95;
    sl.updateTimetolive(SERVICE_NAME, ENDPOINTURL, ttl);
    expectLastCall().andThrow(new WrongArgumentException());
    replay(sl);
    try {
        lps.updateTimetolive(SERVICE_NAME, ENDPOINTURL, ttl);
        fail();
    } catch (ServiceLocatorFault e) {
    // pass
    }
    verify(sl);
}
Also used : WrongArgumentException(org.talend.esb.servicelocator.client.WrongArgumentException) ServiceLocatorFault(org.talend.services.esb.locator.v1.ServiceLocatorFault) Endpoint(org.talend.esb.servicelocator.client.Endpoint) SLEndpoint(org.talend.esb.servicelocator.client.SLEndpoint) Test(org.junit.Test)

Aggregations

ServiceLocatorFault (org.talend.services.esb.locator.v1.ServiceLocatorFault)10 InterruptedExceptionFault (org.talend.services.esb.locator.v1.InterruptedExceptionFault)8 ServiceLocatorException (org.talend.esb.servicelocator.client.ServiceLocatorException)6 InterruptionFaultDetail (org.talend.schemas.esb.locator._2011._11.InterruptionFaultDetail)6 ServiceLocatorFaultDetail (org.talend.schemas.esb.locator._2011._11.ServiceLocatorFaultDetail)6 SLEndpoint (org.talend.esb.servicelocator.client.SLEndpoint)4 QName (javax.xml.namespace.QName)2 Test (org.junit.Test)2 ClassPathXmlApplicationContext (org.springframework.context.support.ClassPathXmlApplicationContext)2 Endpoint (org.talend.esb.servicelocator.client.Endpoint)2 SLPropertiesMatcher (org.talend.esb.servicelocator.client.SLPropertiesMatcher)2 SimpleEndpoint (org.talend.esb.servicelocator.client.SimpleEndpoint)2 LocatorService (org.talend.services.esb.locator.v1.LocatorService)2 ArrayList (java.util.ArrayList)1 DOMResult (javax.xml.transform.dom.DOMResult)1 W3CEndpointReference (javax.xml.ws.wsaddressing.W3CEndpointReference)1 W3CEndpointReferenceBuilder (javax.xml.ws.wsaddressing.W3CEndpointReferenceBuilder)1 BindingType (org.talend.esb.servicelocator.client.BindingType)1 EndpointNotFoundException (org.talend.esb.servicelocator.client.EndpointNotFoundException)1 SLProperties (org.talend.esb.servicelocator.client.SLProperties)1