use of org.talend.mdm.repository.model.mdmproperties.MDMServerDefItem in project tmdm-studio-se by Talend.
the class ServerDefService method getAllServerDefViewObjects.
/**
* Warning: the return result is a encrypted List
*
* @return
*/
public static List<IRepositoryViewObject> getAllServerDefViewObjects(boolean includeDisabledServer) {
IProxyRepositoryFactory factory = CoreRuntimePlugin.getInstance().getProxyRepositoryFactory();
try {
List<IRepositoryViewObject> viewObjects = factory.getAll(REPOSITORY_TYPE_SERVER_DEF);
if (viewObjects != null) {
List<IRepositoryViewObject> serverDefViewObjs = new ArrayList<IRepositoryViewObject>();
for (IRepositoryViewObject viewObj : viewObjects) {
Item item = viewObj.getProperty().getItem();
MDMServerDef serverDef = ((MDMServerDefItem) item).getServerDef();
if (serverDef != null) {
if (tmpPasswordCache.containsKey(viewObj.getId())) {
String tmpPasswd = tmpPasswordCache.get(viewObj.getId());
serverDef.setTempPasswd(tmpPasswd);
}
}
if (serverDef != null) {
if (includeDisabledServer || serverDef.isEnabled()) {
serverDefViewObjs.add(viewObj);
}
}
}
return serverDefViewObjs;
}
return null;
} catch (PersistenceException e) {
log.error(e.getMessage(), e);
}
return null;
}
use of org.talend.mdm.repository.model.mdmproperties.MDMServerDefItem in project tmdm-studio-se by Talend.
the class ServerDefService method createServerDef.
public static String createServerDef(MDMServerDef serverDef) {
IProxyRepositoryFactory factory = CoreRuntimePlugin.getInstance().getProxyRepositoryFactory();
RepositoryContext context = factory.getRepositoryContext();
MDMServerDefItem item = MdmpropertiesFactory.eINSTANCE.createMDMServerDefItem();
item.setServerDef(serverDef);
Property prop = PropertiesFactory.eINSTANCE.createProperty();
item.setProperty(prop);
try {
String nextId = factory.getNextId();
Property property = item.getProperty();
property.setId(nextId);
property.setVersion(VersionUtils.DEFAULT_VERSION);
property.setAuthor(context.getUser());
property.setLabel(item.getServerDef().getName());
// $NON-NLS-1$
factory.create(item, new Path(""));
return nextId;
} catch (PersistenceException e) {
log.error(e.getMessage(), e);
}
return null;
}
use of org.talend.mdm.repository.model.mdmproperties.MDMServerDefItem in project tmdm-studio-se by Talend.
the class UnifyPasswordEncryption4MDMServerDefMigrationTask method execute.
@Override
public ExecutionResult execute(Item item) {
if (item != null && item instanceof MDMServerDefItem) {
MDMServerDef serverDef = ((MDMServerDefItem) item).getServerDef();
String algorithm = serverDef.getAlgorithm();
if (algorithm != null && algorithm.equals(PasswordUtil.ALGORITHM_COMMON)) {
String decryptedPassword = serverDef.getPasswd();
try {
decryptedPassword = PasswordEncryptUtil.decryptPassword(serverDef.getPasswd());
} catch (Exception e) {
return ExecutionResult.FAILURE;
}
serverDef.setPasswd(CryptoHelper.getDefault().encrypt(decryptedPassword));
serverDef.setAlgorithm(PasswordUtil.ALGORITHM_COMMON_V2);
try {
factory.save(item, true);
return ExecutionResult.SUCCESS_NO_ALERT;
} catch (Exception e) {
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
}
}
return ExecutionResult.NOTHING_TO_DO;
// if (modified) {
// factory.save(item, true);
// return ExecutionResult.SUCCESS_NO_ALERT;
// }
// } catch (Exception e) {
// ExceptionHandler.process(e);
// return ExecutionResult.FAILURE;
// }
// return ExecutionResult.NOTHING_TO_DO;
}
use of org.talend.mdm.repository.model.mdmproperties.MDMServerDefItem in project tmdm-studio-se by Talend.
the class SelectServerDefDialog method setSelectServer.
public void setSelectServer(MDMServerDef server) {
if (server == null) {
if (treeViewer.getTree().getItemCount() > 0) {
TreeItem item = treeViewer.getTree().getItem(0);
IRepositoryViewObject viewObject = (IRepositoryViewObject) item.getData();
MDMServerDefItem defitem = (MDMServerDefItem) viewObject.getProperty().getItem();
MDMServerDef defServer = defitem.getServerDef();
serverDef = defServer;
treeViewer.getTree().setSelection(item);
okBun.setEnabled(true);
return;
}
}
TreeItem[] items = treeViewer.getTree().getItems();
for (IRepositoryViewObject viewObject : (List<IRepositoryViewObject>) treeViewer.getInput()) {
MDMServerDefItem defitem = (MDMServerDefItem) viewObject.getProperty().getItem();
MDMServerDef defServer = defitem.getServerDef();
if (server.getName().equals(defServer.getName()) && server.getHost().equals(defServer.getHost()) && server.getPort().equals(defServer.getPort())) {
serverDef = defServer;
treeViewer.setSelection(new StructuredSelection(viewObject));
okBun.setEnabled(true);
break;
}
}
}
use of org.talend.mdm.repository.model.mdmproperties.MDMServerDefItem in project tmdm-studio-se by Talend.
the class ServerSorter method compare.
@Override
public int compare(Viewer viewer, Object e1, Object e2) {
MDMServerDefItem mdmItem1 = getMDMItem((IRepositoryViewObject) e1);
MDMServerDefItem mdmItem2 = getMDMItem((IRepositoryViewObject) e2);
if (mdmItem1 != null && mdmItem2 != null) {
MDMServerDef serverDef1 = mdmItem1.getServerDef();
MDMServerDef serverDef2 = mdmItem2.getServerDef();
boolean enabled1 = serverDef1.isEnabled();
boolean enabled2 = serverDef2.isEnabled();
if (enabled1 == enabled2) {
return serverDef1.getName().toLowerCase().compareTo(serverDef2.getName().toLowerCase());
} else {
return enabled1 ? -1 : 1;
}
}
return 0;
}
Aggregations