Search in sources :

Example 1 with ManagedNode

use of com.centurylink.mdw.workflow.ManagedNode in project mdw-designer by CenturyLinkCloud.

the class MdwWorkbenchWindowAdvisor method getWorkflowProject.

private WorkflowProject getWorkflowProject(String host, String port, String contextRoot) throws DiscoveryException {
    BigInteger portInt = new BigInteger(port);
    WorkflowApplication matchingWorkflowApp = null;
    WorkflowEnvironment matchingWorkflowEnv = null;
    boolean isLocalhost = "localhost".equals(host);
    List<WorkflowApplication> workflowApps = WorkflowProjectManager.getInstance().discoverWorkflowApps();
    for (WorkflowApplication workflowApp : workflowApps) {
        if (isLocalhost) {
            // right info except host and port
            if (workflowApp.getWebContextRoot().equals(contextRoot) || (workflowApp.getServicesContextRoot() != null && workflowApp.getServicesContextRoot().equals(contextRoot))) {
                matchingWorkflowApp = workflowApp;
                matchingWorkflowEnv = workflowApp.getEnvironmentList().get(0);
                ManagedNode server = matchingWorkflowEnv.getManagedServerList().get(0);
                server.setHost(host);
                server.setPort(new BigInteger(port));
                break;
            }
        } else {
            for (WorkflowEnvironment workflowEnv : workflowApp.getEnvironmentList()) {
                for (ManagedNode server : workflowEnv.getManagedServerList()) {
                    if (server.getHost().equals(host) && server.getPort().equals(portInt)) {
                        if (matchingWorkflowEnv == null) {
                            matchingWorkflowEnv = workflowEnv;
                            matchingWorkflowApp = workflowApp;
                        } else {
                            // context root is only used to break a tie
                            if (workflowApp.getWebContextRoot().equals(contextRoot) || (workflowApp.getServicesContextRoot() != null && workflowApp.getServicesContextRoot().equals(contextRoot))) {
                                matchingWorkflowEnv = workflowEnv;
                                matchingWorkflowApp = workflowApp;
                            }
                        }
                    }
                }
            }
        }
    }
    if (matchingWorkflowApp == null)
        return null;
    return new WorkflowProject(matchingWorkflowApp, matchingWorkflowEnv);
}
Also used : WorkflowApplication(com.centurylink.mdw.workflow.WorkflowApplication) WorkflowEnvironment(com.centurylink.mdw.workflow.WorkflowEnvironment) BigInteger(java.math.BigInteger) ManagedNode(com.centurylink.mdw.workflow.ManagedNode) WorkflowProject(com.centurylink.mdw.plugin.project.model.WorkflowProject)

Aggregations

WorkflowProject (com.centurylink.mdw.plugin.project.model.WorkflowProject)1 ManagedNode (com.centurylink.mdw.workflow.ManagedNode)1 WorkflowApplication (com.centurylink.mdw.workflow.WorkflowApplication)1 WorkflowEnvironment (com.centurylink.mdw.workflow.WorkflowEnvironment)1 BigInteger (java.math.BigInteger)1