Search in sources :

Example 6 with TMDMService

use of com.amalto.workbench.webservices.TMDMService in project tmdm-studio-se by Talend.

the class Util method getXSDSchema.

public static XSDSchema getXSDSchema(TreeObject treeObj, String dataModelName) {
    TreeObject dataModelFolder = treeObj.findServerFolder(TreeObject.DATA_MODEL);
    TMDMService port = null;
    try {
        port = Util.getMDMService(dataModelFolder);
    } catch (XtentisException e3) {
        log.error(e3.getMessage(), e3);
    } catch (Exception e3) {
        log.error(e3.getMessage(), e3);
    }
    WSDataModel wsDataModel = null;
    try {
        wsDataModel = port.getDataModel(new WSGetDataModel(new WSDataModelPK(dataModelName)));
        String schema = wsDataModel.getXsdSchema();
        return Util.createXsdSchema(schema, dataModelFolder);
    } catch (Exception e1) {
        log.error(e1.getMessage(), e1);
    }
    return null;
}
Also used : WSDataModel(com.amalto.workbench.webservices.WSDataModel) TMDMService(com.amalto.workbench.webservices.TMDMService) TreeObject(com.amalto.workbench.models.TreeObject) ConnectException(java.net.ConnectException) IOException(java.io.IOException) WebServiceException(javax.xml.ws.WebServiceException) MissingJarsException(com.amalto.workbench.service.MissingJarsException) MalformedURLException(java.net.MalformedURLException) SAXParseException(org.xml.sax.SAXParseException) InaccessibleWSDLException(com.sun.xml.internal.ws.wsdl.parser.InaccessibleWSDLException) WSGetDataModel(com.amalto.workbench.webservices.WSGetDataModel) WSDataModelPK(com.amalto.workbench.webservices.WSDataModelPK)

Example 7 with TMDMService

use of com.amalto.workbench.webservices.TMDMService in project tmdm-studio-se by Talend.

the class Util method checkOnVersionCompatibility.

public static String checkOnVersionCompatibility(String url, String username, String password) {
    IProduct product = Platform.getProduct();
    // $NON-NLS-1$
    String versionComp = "";
    try {
        // $NON-NLS-1$
        URL resourceURL = product.getDefiningBundle().getResource("/about.mappings");
        PropertyResourceBundle bundle = new PropertyResourceBundle(resourceURL.openStream());
        // $NON-NLS-1$
        String studioVersion = bundle.getString("1").trim();
        // $NON-NLS-1$
        Pattern vsnPtn = Pattern.compile("^(\\d+)\\.(\\d+)(\\.)*(\\d*)$");
        Matcher match = vsnPtn.matcher(studioVersion);
        if (!match.find()) {
            return null;
        }
        versionComp = Messages.Util_45 + studioVersion + Messages.Util_46;
        int major = Integer.parseInt(match.group(1));
        int minor = Integer.parseInt(match.group(2));
        // $NON-NLS-1$
        int rev = match.group(4) != null && !match.group(4).equals("") ? Integer.parseInt(match.group(4)) : 0;
        TMDMService service = Util.getMDMService(new URL(url), username, password);
        WSVersion wsVersion = service.getComponentVersion(new WSGetComponentVersion(WSComponent.DATA_MANAGER, null));
        versionComp += Messages.Util_47 + wsVersion.getMajor() + Messages.Util_48 + wsVersion.getMinor() + Messages.Util_49 + wsVersion.getRevision();
        if (major != wsVersion.getMajor() || minor != wsVersion.getMinor()) {
            return versionComp;
        }
        if (rev == 0) {
            // major version compare
            if (wsVersion.getRevision() != 0) {
                return versionComp;
            }
        }
    } catch (Exception e) {
    }
    return null;
}
Also used : Pattern(java.util.regex.Pattern) Matcher(java.util.regex.Matcher) TMDMService(com.amalto.workbench.webservices.TMDMService) WSGetComponentVersion(com.amalto.workbench.webservices.WSGetComponentVersion) IProduct(org.eclipse.core.runtime.IProduct) WSVersion(com.amalto.workbench.webservices.WSVersion) URL(java.net.URL) ConnectException(java.net.ConnectException) IOException(java.io.IOException) WebServiceException(javax.xml.ws.WebServiceException) MissingJarsException(com.amalto.workbench.service.MissingJarsException) MalformedURLException(java.net.MalformedURLException) SAXParseException(org.xml.sax.SAXParseException) InaccessibleWSDLException(com.sun.xml.internal.ws.wsdl.parser.InaccessibleWSDLException) PropertyResourceBundle(java.util.PropertyResourceBundle)

Example 8 with TMDMService

use of com.amalto.workbench.webservices.TMDMService 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 9 with TMDMService

use of com.amalto.workbench.webservices.TMDMService in project tmdm-studio-se by Talend.

the class LocalTreeObjectRepository method startUp.

public void startUp(String ur, String user, String pwd) {
    TMDMService service = null;
    Document doc = null;
    SAXReader saxReader = new SAXReader();
    try {
        service = Util.getMDMService(new URL(ur), user, pwd);
        WSCategoryData category = service.getMDMCategory(null);
        doc = saxReader.read(new StringReader(category.getCategorySchema()));
        saveCredential(ur, user, pwd, doc, service, true);
        doUpgrade(UnifyUrl(ur));
    } catch (Exception e) {
        log.error(e.getMessage(), e);
        // $NON-NLS-1$
        String empty = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
        // $NON-NLS-1$//$NON-NLS-2$
        empty += "<" + ICoreConstants.DEFAULT_CATEGORY_ROOT + "/>";
        WSCategoryData newData = new WSCategoryData();
        newData.setCategorySchema(empty);
        try {
            newData = service.getMDMCategory(newData);
            doc = saxReader.read(new StringReader(newData.getCategorySchema()));
            saveCredential(ur, user, pwd, doc, service, true);
        } catch (Exception e1) {
            saveCredential(ur, user, pwd, doc, service, false);
        }
    }
}
Also used : WSCategoryData(com.amalto.workbench.webservices.WSCategoryData) TMDMService(com.amalto.workbench.webservices.TMDMService) SAXReader(org.dom4j.io.SAXReader) StringReader(java.io.StringReader) Document(org.dom4j.Document) URL(java.net.URL) DocumentException(org.dom4j.DocumentException) UnknownHostException(java.net.UnknownHostException)

Example 10 with TMDMService

use of com.amalto.workbench.webservices.TMDMService in project tmdm-studio-se by Talend.

the class LocalTreeObjectRepository method saveDocument.

private void saveDocument(String url) {
    if (credentials.get(url) != null) {
        TMDMService service = credentials.get(url).service;
        Document doc = credentials.get(url).doc;
        if (doc != null) {
            service.getMDMCategory(new WSCategoryData(doc.asXML()));
        }
    }
}
Also used : WSCategoryData(com.amalto.workbench.webservices.WSCategoryData) TMDMService(com.amalto.workbench.webservices.TMDMService) Document(org.dom4j.Document)

Aggregations

TMDMService (com.amalto.workbench.webservices.TMDMService)41 XtentisException (com.amalto.workbench.utils.XtentisException)18 WSDataClusterPK (com.amalto.workbench.webservices.WSDataClusterPK)10 URL (java.net.URL)10 WebServiceException (javax.xml.ws.WebServiceException)9 WSDataModelPK (com.amalto.workbench.webservices.WSDataModelPK)8 TreeObject (com.amalto.workbench.models.TreeObject)7 MalformedURLException (java.net.MalformedURLException)7 WSDataModel (com.amalto.workbench.webservices.WSDataModel)6 WSGetDataModel (com.amalto.workbench.webservices.WSGetDataModel)6 WSView (com.amalto.workbench.webservices.WSView)6 ParseException (java.text.ParseException)6 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)6 WSDataCluster (com.amalto.workbench.webservices.WSDataCluster)5 WSGetDataCluster (com.amalto.workbench.webservices.WSGetDataCluster)5 WSGetView (com.amalto.workbench.webservices.WSGetView)5 WSPing (com.amalto.workbench.webservices.WSPing)5 Matcher (java.util.regex.Matcher)5 WSDigest (com.amalto.workbench.webservices.WSDigest)4 WSRoutingEngineV2Action (com.amalto.workbench.webservices.WSRoutingEngineV2Action)4