Search in sources :

Example 1 with DiscoveryException

use of com.centurylink.mdw.plugin.designer.DiscoveryException in project mdw-designer by CenturyLinkCloud.

the class MdwWorkbenchWindowAdvisor method postWindowOpen.

public void postWindowOpen() {
    IWorkbenchPage activePage = Activator.getActivePage();
    // check for updates
    // IHandlerService handlerService = (IHandlerService)
    // activePage.getWorkbenchWindow().getService(IHandlerService.class);
    // try
    // {
    // Object result =
    // handlerService.executeCommand("org.eclipse.equinox.p2.ui.sdk.update", null);
    // System.out.println("result: " + result);
    // if (result != null)
    // System.out.println("result class: " + result.getClass().getName());
    // }
    // catch (Exception ex)
    // {
    // ex.printStackTrace();
    // }
    PluginMessages.log("MDW workbench startup...");
    if (activePage != null) {
        activePage.hideActionSet("com.centurylink.mdw.plugin.actionset.tools");
        activePage.hideActionSet("com.centurylink.mdw.plugin.actionset.dev");
        activePage.hideActionSet("com.centurylink.mdw.plugin.actionset.designerClassic");
        activePage.hideActionSet("org.eclipse.ui.edit.text.actionSet.navigation");
        activePage.hideActionSet("org.eclipse.ui.edit.text.actionSet.annotationNavigation");
        activePage.hideActionSet("org.eclipse.ui.externaltools.ExternalToolsSet");
        activePage.showActionSet("org.eclipse.search.menu");
        // make sure the process explorer view is visible
        try {
            ProcessExplorerView processExplorerView = (ProcessExplorerView) activePage.showView("mdw.views.designer.processes");
            if (mdwHost != null && mdwPort != null) {
                final Shell shell = activePage.getActivePart().getSite().getShell();
                BusyIndicator.showWhile(shell.getDisplay(), new Runnable() {

                    public void run() {
                        try {
                            discoveryException = null;
                            projectToImport = getWorkflowProject(mdwHost, mdwPort, mdwContextRoot);
                            if (projectToImport == null)
                                throw new DiscoveryException("Unable to discover workflow app at: " + mdwHost + ":" + mdwPort);
                        } catch (DiscoveryException ex) {
                            discoveryException = ex;
                        }
                    }
                });
                if (discoveryException != null)
                    throw discoveryException;
                WorkflowProject existing = WorkflowProjectManager.getInstance().getRemoteWorkflowProject(projectToImport.getName());
                if (existing != null)
                    WorkflowProjectManager.getInstance().deleteProject(existing);
                ProgressMonitorDialog progMonDlg = new ProgressMonitorDialog(shell);
                ProjectInflator projectInflator = new ProjectInflator(projectToImport, null);
                projectInflator.inflateRemoteProject(progMonDlg);
                ProjectImporter projectImporter = new ProjectImporter(projectToImport);
                projectImporter.doImport();
                processExplorerView.handleRefresh();
                // handle preselected entity
                if (preselectType != null && preselectType.trim().length() > 0 && preselectId != null && preselectId.trim().length() > 0) {
                    if (!preselectType.equals(PRESELECT_PROCESS_INSTANCE))
                        throw new UnsupportedOperationException("Unsupported preselect type: " + preselectType);
                    BusyIndicator.showWhile(shell.getDisplay(), new Runnable() {

                        public void run() {
                            // open the process instance
                            IWorkbenchPage page = MdwPlugin.getActivePage();
                            try {
                                WorkflowProcess instance = getProcessInstance(new Long(preselectId));
                                page.openEditor(instance, "mdw.editors.process");
                                page.showView("org.eclipse.ui.views.PropertySheet");
                            } catch (PartInitException ex) {
                                PluginMessages.uiError(ex, "Open Process Instance", projectToImport);
                            }
                        }
                    });
                }
            }
        } catch (Exception ex) {
            PluginMessages.uiError(ex, "Initialize Workspace");
        }
    }
}
Also used : ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) ProcessExplorerView(com.centurylink.mdw.plugin.designer.views.ProcessExplorerView) WorkflowProject(com.centurylink.mdw.plugin.project.model.WorkflowProject) PartInitException(org.eclipse.ui.PartInitException) DiscoveryException(com.centurylink.mdw.plugin.designer.DiscoveryException) ProjectImporter(com.centurylink.mdw.plugin.project.assembly.ProjectImporter) Shell(org.eclipse.swt.widgets.Shell) ProjectInflator(com.centurylink.mdw.plugin.project.assembly.ProjectInflator) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) PartInitException(org.eclipse.ui.PartInitException) DiscoveryException(com.centurylink.mdw.plugin.designer.DiscoveryException) WorkflowProcess(com.centurylink.mdw.plugin.designer.model.WorkflowProcess)

Example 2 with DiscoveryException

use of com.centurylink.mdw.plugin.designer.DiscoveryException in project mdw-designer by CenturyLinkCloud.

the class WorkflowProjectManager method discoverWorkflowApps.

public List<WorkflowApplication> discoverWorkflowApps() throws DiscoveryException {
    String urlBase = MdwPlugin.getSettings().getProjectDiscoveryUrl();
    if (!urlBase.endsWith("/"))
        urlBase += "/";
    String ctxRoot = urlBase.endsWith("Discovery/") ? "" : "MDWWeb/";
    if (urlBase.indexOf("lxdnd696") >= 0)
        // old discovery server
        ctxRoot = "MDWExampleWeb/";
    String path = urlBase.endsWith("Discovery/") ? "ConfigManagerProjects.xml" : "Services/GetConfigFile?name=ConfigManagerProjects.xml";
    String cfgMgrUrl = urlBase + ctxRoot + path;
    try {
        URL url = new URL(cfgMgrUrl);
        HttpHelper httpHelper = new HttpHelper(url);
        httpHelper.setConnectTimeout(MdwPlugin.getSettings().getHttpConnectTimeout());
        httpHelper.setReadTimeout(MdwPlugin.getSettings().getHttpReadTimeout());
        String xml = httpHelper.get();
        ConfigManagerProjectsDocument doc = ConfigManagerProjectsDocument.Factory.parse(xml, Compatibility.namespaceOptions());
        return doc.getConfigManagerProjects().getWorkflowAppList();
    } catch (XmlException ex) {
        PluginMessages.log(ex);
        throw new DiscoveryException("Unable to obtain/parse Config Manager info from " + cfgMgrUrl);
    } catch (Exception ex) {
        throw new DiscoveryException(ex.getMessage(), ex);
    }
}
Also used : ConfigManagerProjectsDocument(com.centurylink.mdw.workflow.ConfigManagerProjectsDocument) XmlException(org.apache.xmlbeans.XmlException) HttpHelper(com.centurylink.mdw.common.utilities.HttpHelper) DiscoveryException(com.centurylink.mdw.plugin.designer.DiscoveryException) URL(java.net.URL) ResourceException(org.eclipse.core.internal.resources.ResourceException) CoreException(org.eclipse.core.runtime.CoreException) JavaModelException(org.eclipse.jdt.core.JavaModelException) MdwSecurityException(com.centurylink.mdw.auth.MdwSecurityException) DiscoveryException(com.centurylink.mdw.plugin.designer.DiscoveryException) XmlException(org.apache.xmlbeans.XmlException)

Aggregations

DiscoveryException (com.centurylink.mdw.plugin.designer.DiscoveryException)2 MdwSecurityException (com.centurylink.mdw.auth.MdwSecurityException)1 HttpHelper (com.centurylink.mdw.common.utilities.HttpHelper)1 WorkflowProcess (com.centurylink.mdw.plugin.designer.model.WorkflowProcess)1 ProcessExplorerView (com.centurylink.mdw.plugin.designer.views.ProcessExplorerView)1 ProjectImporter (com.centurylink.mdw.plugin.project.assembly.ProjectImporter)1 ProjectInflator (com.centurylink.mdw.plugin.project.assembly.ProjectInflator)1 WorkflowProject (com.centurylink.mdw.plugin.project.model.WorkflowProject)1 ConfigManagerProjectsDocument (com.centurylink.mdw.workflow.ConfigManagerProjectsDocument)1 URL (java.net.URL)1 XmlException (org.apache.xmlbeans.XmlException)1 ResourceException (org.eclipse.core.internal.resources.ResourceException)1 CoreException (org.eclipse.core.runtime.CoreException)1 JavaModelException (org.eclipse.jdt.core.JavaModelException)1 ProgressMonitorDialog (org.eclipse.jface.dialogs.ProgressMonitorDialog)1 Shell (org.eclipse.swt.widgets.Shell)1 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)1 PartInitException (org.eclipse.ui.PartInitException)1