Search in sources :

Example 1 with ServiceLocatorFaultDetail

use of org.talend.schemas.esb.locator._2011._11.ServiceLocatorFaultDetail 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 ServiceLocatorFaultDetail

use of org.talend.schemas.esb.locator._2011._11.ServiceLocatorFaultDetail 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 ServiceLocatorFaultDetail

use of org.talend.schemas.esb.locator._2011._11.ServiceLocatorFaultDetail 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 ServiceLocatorFaultDetail

use of org.talend.schemas.esb.locator._2011._11.ServiceLocatorFaultDetail 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 5 with ServiceLocatorFaultDetail

use of org.talend.schemas.esb.locator._2011._11.ServiceLocatorFaultDetail 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)

Aggregations

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 InterruptedExceptionFault (org.talend.services.esb.locator.v1.InterruptedExceptionFault)6 ServiceLocatorFault (org.talend.services.esb.locator.v1.ServiceLocatorFault)6 SLEndpoint (org.talend.esb.servicelocator.client.SLEndpoint)2 SLPropertiesMatcher (org.talend.esb.servicelocator.client.SLPropertiesMatcher)2 SimpleEndpoint (org.talend.esb.servicelocator.client.SimpleEndpoint)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 SLProperties (org.talend.esb.servicelocator.client.SLProperties)1 SLPropertiesImpl (org.talend.esb.servicelocator.client.SLPropertiesImpl)1 TransportType (org.talend.esb.servicelocator.client.TransportType)1 EndpointTransformerImpl (org.talend.esb.servicelocator.client.internal.EndpointTransformerImpl)1 EntryType (org.talend.schemas.esb.locator._2011._11.EntryType)1 Document (org.w3c.dom.Document)1