use of org.talend.mdm.repository.model.mdmmetadata.MDMServerDef in project tmdm-studio-se by Talend.
the class UndeployAction method doRun.
/*
* (non-Javadoc)
*
* @see org.talend.mdm.repository.core.bridge.AbstractBridgeRepositoryAction#doRun()
*/
@Override
protected void doRun() {
DeployService deployService = DeployService.getInstance();
CommandManager cmanager = CommandManager.getInstance();
List<IRepositoryViewObject> viewObjs = getSelectedRepositoryViewObject();
if (viewObjs.size() < 1) {
return;
}
SelectServerDefDialog dialog = getServerDefDialog(viewObjs);
if (dialog.open() == IDialogConstants.OK_ID) {
MDMServerDef serverDef = dialog.getSelectedServerDef();
List<AbstractDeployCommand> deleteCommands = new ArrayList<AbstractDeployCommand>(viewObjs.size());
for (IRepositoryViewObject obj : viewObjs) {
ICommand deleteCmd = cmanager.getNewCommand(obj, ICommand.CMD_DELETE);
deleteCmd.init(obj);
deleteCommands.add((AbstractDeployCommand) deleteCmd);
}
IStatus status = deployService.runCommands(deleteCommands, serverDef);
IProgressMonitor monitor = new NullProgressMonitor();
deployService.updateChangedStatus(status);
if (status.isMultiStatus()) {
new DeployStatusDialog(getShell(), status).open();
}
for (IRepositoryViewObject viewObj : viewObjs) {
MDMServerDef lastServerDef = RepositoryResourceUtil.getLastServerDef(viewObj);
String id = viewObj.getId();
CommandStack stack = cmanager.findCommandStack(id);
if (stack != null) {
if (RepositoryResourceUtil.isSameMDMServerDef(lastServerDef, serverDef)) {
List<ICommand> commands = stack.getCommands(ICommand.PHASE_RESTORE);
for (ICommand cmd : commands) {
cmd.execute(null, monitor);
}
}
cmanager.removeCommandStack(id, ICommand.PHASE_RESTORE);
commonViewer.refresh(viewObj);
}
}
} else {
return;
}
}
use of org.talend.mdm.repository.model.mdmmetadata.MDMServerDef in project tmdm-studio-se by Talend.
the class JobInteractiveHandler method doRemove.
@Override
public boolean doRemove(TMDMService service, AbstractDeployCommand cmd) throws XtentisException {
MDMServerDef serverDef = cmd.getServerDef();
String name = cmd.getObjName();
String version = cmd.getViewObject().getVersion();
// delete server bar file
// $NON-NLS-1$ //$NON-NLS-2$
String filename = name + "_" + version + ".zip";
String contextPath = Util.getContextPath(serverDef.getPath());
String uploadURL = // $NON-NLS-1$
serverDef.getProtocol() + serverDef.getHost() + ":" + serverDef.getPort() + contextPath + "/services/uploadFile?deletefile=" + // $NON-NLS-1$
filename;
HttpClientUtil.uploadFileToAppServer(uploadURL, filename, serverDef.getUser(), serverDef.getPasswd());
// $NON-NLS-1$ //$NON-NLS-2$
filename = name + "_" + version + ".war";
uploadURL = // $NON-NLS-1$
serverDef.getProtocol() + serverDef.getHost() + ":" + serverDef.getPort() + contextPath + "/services/uploadFile?deletefile=" + // $NON-NLS-1$
filename;
HttpClientUtil.uploadFileToAppServer(uploadURL, filename, serverDef.getUser(), serverDef.getPasswd());
return true;
}
use of org.talend.mdm.repository.model.mdmmetadata.MDMServerDef 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.mdmmetadata.MDMServerDef 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.mdmmetadata.MDMServerDef 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;
}
}
}
Aggregations