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