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);
}
}
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();
}
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);
}
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);
}
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);
}
Aggregations