Search in sources :

Example 61 with MDMServerDef

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;
    }
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) CommandStack(org.talend.mdm.repository.core.command.CommandStack) IStatus(org.eclipse.core.runtime.IStatus) DeployStatusDialog(org.talend.mdm.repository.ui.dialogs.deploy.DeployStatusDialog) ArrayList(java.util.ArrayList) DeployService(org.talend.mdm.repository.core.service.DeployService) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) CommandManager(org.talend.mdm.repository.core.command.CommandManager) ICommand(org.talend.mdm.repository.core.command.ICommand) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) SelectServerDefDialog(org.talend.mdm.workbench.serverexplorer.ui.dialogs.SelectServerDefDialog) AbstractDeployCommand(org.talend.mdm.repository.core.command.deploy.AbstractDeployCommand) MDMServerDef(org.talend.mdm.repository.model.mdmmetadata.MDMServerDef)

Example 62 with MDMServerDef

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;
}
Also used : MDMServerDef(org.talend.mdm.repository.model.mdmmetadata.MDMServerDef)

Example 63 with MDMServerDef

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;
}
Also used : MDMServerDefItem(org.talend.mdm.repository.model.mdmproperties.MDMServerDefItem) Item(org.talend.core.model.properties.Item) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) ArrayList(java.util.ArrayList) MDMServerDefItem(org.talend.mdm.repository.model.mdmproperties.MDMServerDefItem) PersistenceException(org.talend.commons.exception.PersistenceException) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory) MDMServerDef(org.talend.mdm.repository.model.mdmmetadata.MDMServerDef)

Example 64 with MDMServerDef

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;
}
Also used : MDMServerDefItem(org.talend.mdm.repository.model.mdmproperties.MDMServerDefItem) MDMServerDef(org.talend.mdm.repository.model.mdmmetadata.MDMServerDef)

Example 65 with MDMServerDef

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;
        }
    }
}
Also used : TreeItem(org.eclipse.swt.widgets.TreeItem) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) MDMServerDefItem(org.talend.mdm.repository.model.mdmproperties.MDMServerDefItem) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) List(java.util.List) MDMServerDef(org.talend.mdm.repository.model.mdmmetadata.MDMServerDef)

Aggregations

MDMServerDef (org.talend.mdm.repository.model.mdmmetadata.MDMServerDef)66 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)36 SelectServerDefDialog (org.talend.mdm.workbench.serverexplorer.ui.dialogs.SelectServerDefDialog)15 Item (org.talend.core.model.properties.Item)11 MDMServerDefItem (org.talend.mdm.repository.model.mdmproperties.MDMServerDefItem)10 MDMServerObjectItem (org.talend.mdm.repository.model.mdmproperties.MDMServerObjectItem)10 IStatus (org.eclipse.core.runtime.IStatus)8 MDMServerObject (org.talend.mdm.repository.model.mdmserverobject.MDMServerObject)8 PersistenceException (org.talend.commons.exception.PersistenceException)7 AbstractDeployCommand (org.talend.mdm.repository.core.command.deploy.AbstractDeployCommand)7 TMDMService (com.amalto.workbench.webservices.TMDMService)6 CommandManager (org.talend.mdm.repository.core.command.CommandManager)6 IProxyRepositoryFactory (org.talend.repository.model.IProxyRepositoryFactory)6 TreeObject (com.amalto.workbench.models.TreeObject)5 XtentisException (com.amalto.workbench.utils.XtentisException)5 ArrayList (java.util.ArrayList)5 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)5 Test (org.junit.Test)5 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)5 LinkedList (java.util.LinkedList)4