Search in sources :

Example 1 with MissingJarsException

use of com.amalto.workbench.service.MissingJarsException 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;
}
Also used : WSPing(com.amalto.workbench.webservices.WSPing) MissingJarsException(com.amalto.workbench.service.MissingJarsException) WebServiceException(javax.xml.ws.WebServiceException) TMDMService(com.amalto.workbench.webservices.TMDMService) XObject(com.sun.org.apache.xpath.internal.objects.XObject) TreeObject(com.amalto.workbench.models.TreeObject) EObject(org.eclipse.emf.ecore.EObject) IWebServiceHook(com.amalto.workbench.service.IWebServiceHook) BindingProvider(javax.xml.ws.BindingProvider) TMDMService_Service(com.amalto.workbench.webservices.TMDMService_Service)

Example 2 with MissingJarsException

use of com.amalto.workbench.service.MissingJarsException in project tmdm-studio-se by Talend.

the class ServerDefDialog method buttonPressed.

@Override
protected void buttonPressed(int buttonId) {
    if (buttonId == IDialogConstants.OK_ID) {
        if (!validateInput()) {
            return;
        }
        updateUI2Model(serverDef);
    }
    if (buttonId == CHECK_CONNECTION_ID) {
        if (!validateInput()) {
            return;
        }
        MDMServerDef tmpServerDef = MdmmetadataFactory.eINSTANCE.createMDMServerDef();
        tmpServerDef.setAlgorithm(PasswordUtil.ALGORITHM_COMMON_V2);
        updateUI2Model(tmpServerDef);
        try {
            ServerDefService.checkMDMConnection(tmpServerDef.getDecryptedServerDef());
            setMessage(Messages.ServerExplorer_ConnectSuccessful);
        } catch (MissingJarsException e) {
            return;
        } catch (XtentisException e) {
            setErrorMessage(Messages.ServerExplorer_ConnectFailed);
        } catch (MalformedURLException e) {
            setErrorMessage(Messages.ServerExplorer_ConnectFailed);
        }
    }
    super.buttonPressed(buttonId);
}
Also used : MalformedURLException(java.net.MalformedURLException) MissingJarsException(com.amalto.workbench.service.MissingJarsException) MDMServerDef(org.talend.mdm.repository.model.mdmmetadata.MDMServerDef) XtentisException(com.amalto.workbench.utils.XtentisException)

Aggregations

MissingJarsException (com.amalto.workbench.service.MissingJarsException)2 TreeObject (com.amalto.workbench.models.TreeObject)1 IWebServiceHook (com.amalto.workbench.service.IWebServiceHook)1 XtentisException (com.amalto.workbench.utils.XtentisException)1 TMDMService (com.amalto.workbench.webservices.TMDMService)1 TMDMService_Service (com.amalto.workbench.webservices.TMDMService_Service)1 WSPing (com.amalto.workbench.webservices.WSPing)1 XObject (com.sun.org.apache.xpath.internal.objects.XObject)1 MalformedURLException (java.net.MalformedURLException)1 BindingProvider (javax.xml.ws.BindingProvider)1 WebServiceException (javax.xml.ws.WebServiceException)1 EObject (org.eclipse.emf.ecore.EObject)1 MDMServerDef (org.talend.mdm.repository.model.mdmmetadata.MDMServerDef)1