Search in sources :

Example 1 with WSCategoryData

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

use of com.amalto.workbench.webservices.WSCategoryData 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)2 WSCategoryData (com.amalto.workbench.webservices.WSCategoryData)2 Document (org.dom4j.Document)2 StringReader (java.io.StringReader)1 URL (java.net.URL)1 UnknownHostException (java.net.UnknownHostException)1 DocumentException (org.dom4j.DocumentException)1 SAXReader (org.dom4j.io.SAXReader)1