use of com.amalto.workbench.service.IWebServiceHook in project tmdm-studio-se by Talend.
the class Util method getMDMService.
public static TMDMService getMDMService(URL url, final String username, final String password, boolean showMissingJarDialog) throws XtentisException {
url = checkAndAddSuffix(url);
boolean needCheck = true;
TMDMService service = (TMDMService) cachedMDMService.get(url, username, password);
if (service == null) {
needCheck = false;
boolean checkResult = MissingJarService.getInstance().checkMissingJar(showMissingJarDialog);
if (!checkResult) {
// $NON-NLS-1$
throw new MissingJarsException("Missing dependency libraries.");
}
try {
TMDMService_Service service_service = new TMDMService_Service(url);
service = service_service.getTMDMPort();
BindingProvider stub = (BindingProvider) service;
// Do not maintain session via cookies
stub.getRequestContext().put(BindingProvider.SESSION_MAINTAIN_PROPERTY, false);
Map<String, Object> context = stub.getRequestContext();
// // dynamic set endpointAddress
// context.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, endpointAddress);
// authentication
context.put(BindingProvider.USERNAME_PROPERTY, username);
context.put(BindingProvider.PASSWORD_PROPERTY, password);
IWebServiceHook wsHook = getWebServiceHook();
if (wsHook != null) {
wsHook.preRequestSendingHook(stub, username);
}
cachedMDMService.put(url, username, password, service);
} catch (WebServiceException e) {
XtentisException ex = convertWebServiceException(e);
log.error(Messages.bind(Messages.UnableAccessEndpoint, url, e.getMessage()), e);
if (ex != null) {
throw ex;
}
}
}
if (needCheck) {
try {
service.ping(new WSPing());
} catch (WebServiceException e) {
cachedMDMService.remove(url, username, password);
XtentisException ex = convertWebServiceException(e);
log.error(Messages.bind(Messages.UnableAccessEndpoint, url, e.getMessage()), e);
if (ex != null) {
throw ex;
}
}
}
return service;
}
use of com.amalto.workbench.service.IWebServiceHook in project tmdm-studio-se by Talend.
the class HttpClientUtil method getStudioToken.
public static String[] getStudioToken(String userName) {
IWebServiceHook webServiceHook = Util.getWebServiceHook();
if (webServiceHook != null) {
String[] tokenPair = new String[2];
tokenPair[0] = webServiceHook.getTokenKey();
tokenPair[1] = webServiceHook.buildStudioToken(userName);
return tokenPair;
}
return null;
}
Aggregations