/** Initialize the fields in this editor. */
  protected void initialize() {
    if (ports == null) return;

    ports.removeAll();
    CarbonServer31Utils.isServerStartBrowserPopup(server.getOriginal());
    ServerPort[] serverPorts =
        ServerController.getInstance().getServerManager().getServerPorts(server.getOriginal());
    for (ServerPort serverPort : serverPorts) {
      ServerPort port = serverPort;
      TableItem item = new TableItem(ports, SWT.NONE);
      String portStr = "-";
      if (port.getPort() >= 0) portStr = port.getPort() + "";
      String[] s = new String[] {port.getName(), portStr};
      item.setText(s);
      int i = CarbonServerConstants.PORT_CAPTIONS.indexOf(port.getName());
      if (i != -1) {
        port =
            new ServerPort(
                CarbonServerConstants.PORT_IDS.get(i),
                port.getName(),
                port.getPort(),
                port.getProtocol());
      }
      item.setData(port);
    }

    if (readOnly) {
      viewer.setCellEditors(new CellEditor[] {null, null});
      viewer.setCellModifier(null);
    } else {
      setupPortEditors();
    }
  }
 public static void cleanupServerConfigurations(IServer server) throws Exception {
   IServerManager wsasServerManager = ServerController.getInstance().getServerManager();
   HashMap<String, Object> operationParameters = new HashMap<String, Object>();
   operationParameters.put(
       ICarbonOperationManager.PARAMETER_TYPE,
       ICarbonOperationManager.OPERATION_CLEANUP_SERVER_CONFIGURATIONS);
   wsasServerManager.executeOperationOnServer(server, operationParameters);
 }
 public void publishModule(int kind, int deltaKind, IModule[] module, IProgressMonitor monitor)
     throws CoreException {
   IModule m = module[module.length - 1];
   if (deltaKind == ADDED) {
     checkClosed(module);
     ServerController.getInstance()
         .getServerManager()
         .publishServiceModule(getServer().getId(), "", m.getName());
   } else if (deltaKind == REMOVED) {
     ServerController.getInstance()
         .getServerManager()
         .unpublishServiceModule(getServer().getId(), "", m.getName());
   } else {
     checkClosed(module);
     // To add any new services
     ServerController.getInstance()
         .getServerManager()
         .hotUpdateServiceModule(getServer().getId(), "", m.getName());
   }
   setModulePublishState(module, null);
 }
 public static boolean isOperationSupported(IServer server, int operation) throws Exception {
   IServerManager wsasServerManager = ServerController.getInstance().getServerManager();
   HashMap<String, Object> operationParameters = new HashMap<String, Object>();
   operationParameters.put(
       ICarbonOperationManager.PARAMETER_TYPE,
       ICarbonOperationManager.OPERATION_SUPPORTED_OPERATIONS);
   operationParameters.put(ICarbonOperationManager.PARAMETER_OP_TYPES, operation);
   Object r = wsasServerManager.executeOperationOnServer(server, operationParameters);
   if (r instanceof Boolean) {
     return (Boolean) r;
   }
   return false;
 }
 public static String getServerAuthenticatedCookie(IServer server, String httpsPort)
     throws Exception {
   String result = null;
   if (server != null) {
     IServerManager esbServerManager = ServerController.getInstance().getServerManager();
     HashMap<String, Object> operationParameters = new HashMap<String, Object>();
     operationParameters.put(
         ICarbonOperationManager.PARAMETER_TYPE,
         ICarbonOperationManager.OPERATION_GET_SERVER_AUTHENTICATED_COOKIE);
     operationParameters.put(ICarbonOperationManager.PARAMETER_SERVER_PORT, httpsPort);
     Object r = esbServerManager.executeOperationOnServer(server, operationParameters);
     if (r instanceof String) {
       result = (String) r;
     }
   }
   return result;
 }
 public static String[] getServerCodegenLibraries(IServer server) throws Exception {
   String[] result = null;
   if (server != null) {
     IServerManager wsasServerManager = ServerController.getInstance().getServerManager();
     HashMap<String, Object> operationParameters = new HashMap<String, Object>();
     operationParameters.put(
         ICarbonOperationManager.PARAMETER_TYPE,
         ICarbonOperationManager.OPERATION_GET_CODEGEN_LIBRARIES);
     Object r =
         wsasServerManager.executeOperationOnServer(
             server, operationParameters); // getWSDLConversionResultUrl(resourceFile);
     if (r instanceof String[]) {
       result = (String[]) r;
     }
   }
   return result;
 }
 public boolean publishServiceModule(String serverId, String webTempPath, String projectName) {
   IServer server = getServer(serverId);
   IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
   IServerManager wsasServerManager = ServerController.getInstance().getServerManager();
   HashMap<String, Object> operationParameters = new HashMap<String, Object>();
   operationParameters.put(
       ICarbonOperationManager.PARAMETER_TYPE, ICarbonOperationManager.OPERATION_PUBLISH_MODULE);
   operationParameters.put(ICarbonOperationManager.PARAMETER_WebTempPath, webTempPath);
   operationParameters.put(ICarbonOperationManager.PARAMETER_PROJECT, project);
   try {
     wsasServerManager.executeOperationOnServer(server, operationParameters);
     return true;
   } catch (Exception e) {
     log.error(e);
     return false;
   }
 }
 public static String getServerCarbonVersion(IServer server) {
   String result = null;
   if (server != null) {
     IServerManager wsasServerManager = ServerController.getInstance().getServerManager();
     HashMap<String, Object> operationParameters = new HashMap<String, Object>();
     operationParameters.put(
         ICarbonOperationManager.PARAMETER_TYPE, ICarbonOperationManager.OPERATION_SERVER_VERSION);
     Object r = null;
     try {
       r = wsasServerManager.executeOperationOnServer(server, operationParameters);
     } catch (Exception e) {
       // TODO Auto-generated catch block
       e.printStackTrace();
     } // getWSDLConversionResultUrl(resourceFile);
     result = (String) r;
   }
   return result;
 }
 public static Map<IFolder, IProject> getPublishedPaths(IServer server) {
   if (server == null) return null;
   IServerManager wsasServerManager = ServerController.getInstance().getServerManager();
   HashMap<String, Object> operationParameters = new HashMap<String, Object>();
   operationParameters.put(
       ICarbonOperationManager.PARAMETER_TYPE,
       ICarbonOperationManager.OPERATION_GET_PUBLISHED_SERVICES);
   try {
     Object result = wsasServerManager.executeOperationOnServer(server, operationParameters);
     if (result instanceof Map) {
       return (Map<IFolder, IProject>) result;
     }
     return null;
   } catch (Exception e) {
     log.error(e);
     return null;
   }
 }
 public static URL getServiceTryItUrl(IServer server, String serviceName) throws Exception {
   URL result = null;
   if (server != null) {
     IServerManager wsasServerManager = ServerController.getInstance().getServerManager();
     HashMap<String, Object> operationParameters = new HashMap<String, Object>();
     operationParameters.put(
         ICarbonOperationManager.PARAMETER_TYPE,
         ICarbonOperationManager.OPERATION_GET_SERVICE_TRY_IT_URL);
     operationParameters.put(ICarbonOperationManager.PARAMETER_SERVICE_NAME, serviceName);
     Object r =
         wsasServerManager.executeOperationOnServer(
             server, operationParameters); // getWSDLConversionResultUrl(resourceFile);
     if (r instanceof URL) {
       result = (URL) r;
     }
   }
   return result;
 }
 public static void serverAdded(IServer server) {
   ICarbonOperationManager serverOperationManager = getServerOperationManager(server);
   if (serverOperationManager != null) {
     getServers().add(server);
     isServerAdded = true;
     IServerManager wsasServerManager = ServerController.getInstance().getServerManager();
     HashMap<String, Object> operationParameters = new HashMap<String, Object>();
     operationParameters.put(
         ICarbonOperationManager.PARAMETER_TYPE,
         ICarbonOperationManager.OPERATION_GET_SERVER_PORTS);
     Object r;
     CarbonServerInformation serverInformation = new CarbonServerInformation();
     serverInformation.setServerId(server.getId());
     ServerPort[] wsasPorts = new ServerPort[] {};
     try {
       r = wsasServerManager.executeOperationOnServer(server, operationParameters);
       if (r instanceof ServerPort[]) wsasPorts = (ServerPort[]) r;
       CarbonServerUtils.setServicePath(server);
     } catch (NoSuchCarbonOperationDefinedException e) {
       // ports cannot be retrieved
     } catch (Exception e) {
       log.error(e);
     }
     serverInformation.setServerPorts(wsasPorts);
     // The localrepo path is for now is the bin distribution path. this
     // needs to be fixed in order to be set inside the workspace path
     // String workspaceRootPath =
     // ResourcesPlugin.getWorkspace().getRoot().getLocation().toOSString();
     // String serverPath=FileUtils.addNodesToPath(workspaceRootPath, new
     // String[]{".metadata",".carbon",server.getId()});
     IPath serverHome = getServerHome(server);
     if (serverHome != null) {
       String serverPath = serverHome.toOSString();
       (new File(serverPath)).mkdirs();
       serverInformation.setServerLocalWorkspacePath(serverPath);
     }
     getAppServerInformation().put(server, serverInformation);
     try {
       initializeServerConfigurations(server);
     } catch (Exception e) {
       log.error(e);
     }
   }
 }
 public static URL getServerURL(IServer server) throws Exception {
   if (server != null) {
     IServerManager esbServerManager = ServerController.getInstance().getServerManager();
     HashMap<String, Object> operationParameters = new HashMap<String, Object>();
     operationParameters.put(
         ICarbonOperationManager.PARAMETER_TYPE, ICarbonOperationManager.OPERATION_SERVER_URL);
     Object serverURL = esbServerManager.executeOperationOnServer(server, operationParameters);
     if (serverURL instanceof URL) {
       String serverId = server.getServerType().getId();
       URL urlWithContextRoot = (URL) serverURL;
       if (!CARBON_SERVER_TYPE_REMOTE.equals(serverId)) {
         urlWithContextRoot =
             new URL(urlWithContextRoot, CarbonServerUtils.getWebContextRoot(server));
       }
       return urlWithContextRoot;
     }
   }
   return null;
 }
 public static ICredentials getServerCredentials(IServer server) throws Exception {
   Map<String, String> result = null;
   if (server != null) {
     IServerManager esbServerManager = ServerController.getInstance().getServerManager();
     HashMap<String, Object> operationParameters = new HashMap<String, Object>();
     operationParameters.put(
         ICarbonOperationManager.PARAMETER_TYPE,
         ICarbonOperationManager.OPERATION_GET_SERVER_CREDENTIALS);
     Object r =
         esbServerManager.executeOperationOnServer(
             server, operationParameters); // getWSDLConversionResultUrl(resourceFile);
     if (r instanceof Map) {
       result = (Map<String, String>) r;
     }
   }
   Credentials credentials = null;
   if (result != null) {
     credentials = new Credentials(result.get("esb.username"), result.get("esb.password"));
   }
   return credentials;
 }
 public static String[] getServerLibraryPaths(IServer server) throws Exception {
   String[] result = null;
   if (server != null) {
     IServerManager wsasServerManager = ServerController.getInstance().getServerManager();
     HashMap<String, Object> operationParameters = new HashMap<String, Object>();
     operationParameters.put(
         ICarbonOperationManager.PARAMETER_TYPE,
         ICarbonOperationManager.OPERATION_GET_LIBRARY_PATHS);
     Object r =
         wsasServerManager.executeOperationOnServer(
             server, operationParameters); // getWSDLConversionResultUrl(resourceFile);
     if (r instanceof String[]) {
       result = (String[]) r;
       IPath serverLocation = getServerHome(server);
       for (int i = 0; i < result.length; i++) {
         result[i] = FileUtils.addAnotherNodeToPath(serverLocation.toOSString(), result[i]);
       }
     }
   }
   return result;
 }