Search in sources :

Example 21 with ServiceLocatorException

use of org.talend.esb.servicelocator.client.ServiceLocatorException in project tesb-rt-se by Talend.

the class LocatorRestServiceTest method registerEndpointExpectedLocatorException.

@Test(expected = WebApplicationException.class)
public void registerEndpointExpectedLocatorException() throws ServiceLocatorException, InterruptedException {
    sl.register(endpoint(), EasyMock.eq(true));
    EasyMock.expectLastCall().andStubThrow(new ServiceLocatorException("test"));
    replayAll();
    RegisterEndpointRequest req = new RegisterEndpointRequest();
    EntryType entryType = new EntryType();
    entryType.setKey("test");
    entryType.getValue().add("test");
    req.getEntryType().add(entryType);
    req.setEndpointURL(ENDPOINTURL);
    req.setServiceName(SERVICE_NAME.toString());
    lps.registerEndpoint(req);
}
Also used : RegisterEndpointRequest(org.talend.schemas.esb.locator.rest._2011._11.RegisterEndpointRequest) EntryType(org.talend.schemas.esb.locator.rest._2011._11.EntryType) ServiceLocatorException(org.talend.esb.servicelocator.client.ServiceLocatorException) Test(org.junit.Test)

Example 22 with ServiceLocatorException

use of org.talend.esb.servicelocator.client.ServiceLocatorException in project tesb-rt-se by Talend.

the class LocatorSoapServiceImpl method registerEndpoint.

/**
 * Register the endpoint for given service.
 *
 * @param input
 *            RegisterEndpointRequestType encapsulate name of service and
 *            endpointURL. Must not be <code>null</code>
 */
@Override
public void registerEndpoint(QName serviceName, String endpointURL, org.talend.schemas.esb.locator._2011._11.BindingType binding, org.talend.schemas.esb.locator._2011._11.TransportType transport, SLPropertiesType properties) throws ServiceLocatorFault, InterruptedExceptionFault {
    if (LOG.isLoggable(Level.FINE)) {
        LOG.fine("Registering endpoint " + endpointURL + " for service " + serviceName + "...");
    }
    try {
        initLocator();
        BindingType bindingType = binding == null ? BindingType.SOAP11 : BindingType.valueOf(binding.value());
        TransportType transportType = transport == null ? TransportType.HTTP : TransportType.valueOf(transport.value());
        SLPropertiesImpl slProps = null;
        if (properties != null) {
            slProps = new SLPropertiesImpl();
            List<EntryType> entries = properties.getEntry();
            for (EntryType entry : entries) {
                slProps.addProperty(entry.getKey(), entry.getValue());
            }
        }
        SimpleEndpoint eprProvider = new SimpleEndpoint(serviceName, endpointURL, bindingType, transportType, slProps);
        locatorClient.register(eprProvider, true);
    } 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 : EntryType(org.talend.schemas.esb.locator._2011._11.EntryType) SimpleEndpoint(org.talend.esb.servicelocator.client.SimpleEndpoint) InterruptionFaultDetail(org.talend.schemas.esb.locator._2011._11.InterruptionFaultDetail) BindingType(org.talend.esb.servicelocator.client.BindingType) ServiceLocatorException(org.talend.esb.servicelocator.client.ServiceLocatorException) SLPropertiesImpl(org.talend.esb.servicelocator.client.SLPropertiesImpl) TransportType(org.talend.esb.servicelocator.client.TransportType) 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 23 with ServiceLocatorException

use of org.talend.esb.servicelocator.client.ServiceLocatorException in project tesb-rt-se by Talend.

the class LocatorSoapServiceImpl method unregisterEndpoint.

/**
 * Unregister the endpoint for given service.
 *
 * @param input
 *            UnregisterEndpointRequestType encapsulate name of service and
 *            endpointURL. Must not be <code>null</code>
 */
@Override
public void unregisterEndpoint(QName serviceName, String endpointURL) throws ServiceLocatorFault, InterruptedExceptionFault {
    if (LOG.isLoggable(Level.FINE)) {
        LOG.fine("Unregistering endpoint " + endpointURL + " for service " + serviceName + "...");
    }
    try {
        initLocator();
        locatorClient.unregister(serviceName, endpointURL);
    } 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 24 with ServiceLocatorException

use of org.talend.esb.servicelocator.client.ServiceLocatorException in project tesb-rt-se by Talend.

the class LocatorSoapServiceImpl method lookupEndpoints.

/**
 * For the given service name return list of endpoint references currently
 * registered at the service locator server endpoints.
 *
 * @param serviceName
 *            the name of the service for which to get the endpoints, must
 *            not be <code>null</code>
 * @return EndpointReferenceListType encapsulate list of endpoint references
 *         or <code>null</code>
 */
List<W3CEndpointReference> lookupEndpoints(QName serviceName, MatcherDataType matcherData) throws ServiceLocatorFault, InterruptedExceptionFault {
    SLPropertiesMatcher matcher = createMatcher(matcherData);
    List<String> names = null;
    List<W3CEndpointReference> result = new ArrayList<W3CEndpointReference>();
    String adress;
    try {
        initLocator();
        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()) {
        for (int i = 0; i < names.size(); i++) {
            adress = names.get(i);
            result.add(buildEndpoint(serviceName, adress));
        }
    } else {
        if (LOG.isLoggable(Level.WARNING)) {
            LOG.log(Level.WARNING, "lookup Endpoints 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 result;
}
Also used : ArrayList(java.util.ArrayList) SLPropertiesMatcher(org.talend.esb.servicelocator.client.SLPropertiesMatcher) ServiceLocatorFault(org.talend.services.esb.locator.v1.ServiceLocatorFault) InterruptedExceptionFault(org.talend.services.esb.locator.v1.InterruptedExceptionFault) SimpleEndpoint(org.talend.esb.servicelocator.client.SimpleEndpoint) SLEndpoint(org.talend.esb.servicelocator.client.SLEndpoint) ServiceLocatorFaultDetail(org.talend.schemas.esb.locator._2011._11.ServiceLocatorFaultDetail) InterruptionFaultDetail(org.talend.schemas.esb.locator._2011._11.InterruptionFaultDetail) W3CEndpointReference(javax.xml.ws.wsaddressing.W3CEndpointReference) ServiceLocatorException(org.talend.esb.servicelocator.client.ServiceLocatorException)

Example 25 with ServiceLocatorException

use of org.talend.esb.servicelocator.client.ServiceLocatorException in project tesb-rt-se by Talend.

the class RegisterEndpointProviderTest method unregisterEndpointDeleteFails.

@Ignore
@Test
public void unregisterEndpointDeleteFails() throws Exception {
    endpointExists(ENDPOINT_PATH_11);
    getData(ENDPOINT_PATH_11, OLD_DATA);
    data2Ep(SERVICE_QNAME_1, OLD_DATA);
    delete(ENDPOINT_STATUS_PATH_11, new KeeperException.RuntimeInconsistencyException());
    Endpoint eprProvider = create(SERVICE_QNAME_1, ENDPOINT_1);
    replayAll();
    ServiceLocatorImpl slc = createServiceLocatorSuccess();
    slc.setEndpointTransformer(trans);
    try {
        slc.unregister(eprProvider);
        fail("A ServiceLocatorException should have been thrown.");
    } catch (ServiceLocatorException e) {
        ignore("Expected exception");
    }
    verifyAll();
}
Also used : Endpoint(org.talend.esb.servicelocator.client.Endpoint) SLEndpoint(org.talend.esb.servicelocator.client.SLEndpoint) ServiceLocatorException(org.talend.esb.servicelocator.client.ServiceLocatorException) KeeperException(org.apache.zookeeper.KeeperException) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

ServiceLocatorException (org.talend.esb.servicelocator.client.ServiceLocatorException)35 Test (org.junit.Test)13 QName (javax.xml.namespace.QName)11 SLEndpoint (org.talend.esb.servicelocator.client.SLEndpoint)8 WebApplicationException (javax.ws.rs.WebApplicationException)6 InterruptionFaultDetail (org.talend.schemas.esb.locator._2011._11.InterruptionFaultDetail)6 ServiceLocatorFaultDetail (org.talend.schemas.esb.locator._2011._11.ServiceLocatorFaultDetail)6 InterruptedExceptionFault (org.talend.services.esb.locator.v1.InterruptedExceptionFault)6 ServiceLocatorFault (org.talend.services.esb.locator.v1.ServiceLocatorFault)6 UnsupportedEncodingException (java.io.UnsupportedEncodingException)4 ServiceLocatorTracker (org.talend.esb.locator.tracker.ServiceLocatorTracker)4 SLPropertiesMatcher (org.talend.esb.servicelocator.client.SLPropertiesMatcher)4 SimpleEndpoint (org.talend.esb.servicelocator.client.SimpleEndpoint)4 JAXBException (javax.xml.bind.JAXBException)3 Endpoint (org.talend.esb.servicelocator.client.Endpoint)3 DOMResult (javax.xml.transform.dom.DOMResult)2 W3CEndpointReferenceBuilder (javax.xml.ws.wsaddressing.W3CEndpointReferenceBuilder)2 EndpointReferenceType (org.apache.cxf.ws.addressing.EndpointReferenceType)2 BindingType (org.talend.esb.servicelocator.client.BindingType)2 SLProperties (org.talend.esb.servicelocator.client.SLProperties)2