public void createControl(Composite parent) {
    selectedPermissions = new ArrayList<RoleData>();
    GridData gd;
    Composite container = new Composite(parent, SWT.NULL);
    checkBoxes = new ArrayList<Button>();
    GridLayout layout = new GridLayout();
    container.setLayout(layout);
    layout.numColumns = 1;
    layout.verticalSpacing = 10;
    gd = new GridData(GridData.FILL_HORIZONTAL);
    try {
      loadData();
    } catch (RemoteException e) {
      log.error(e);
    } catch (Exception e) {
      log.error(e);
    }
    for (int i = 0; i < permissionList.length; i++) {
      if (roleData != null) {
        createCheckbox(permissionList[i], gd, container, i, roleData);
      }
    }

    gd = new GridData(GridData.FILL_HORIZONTAL);
    Label label = new Label(container, SWT.NULL);
    label.setText("Selected Resource paths");
    label.setLayoutData(gd);
    list = new List(container, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL);
    gd = new GridData(GridData.FILL_BOTH);
    list.setLayoutData(gd);
    selectedIemList = new ArrayList<RegistryResourceNode>();
    fillTextArea(selectedIemList);
    setControl(container);
  }
 private List<String> getPackages(
     List<String> exportedPackagesList, MavenProject mavenProject, String packagetype)
     throws CoreException, JavaModelException, Exception {
   List<Plugin> plugins = mavenProject.getBuild().getPlugins();
   for (Plugin plugin : plugins) {
     if ("maven-bundle-plugin".equalsIgnoreCase(plugin.getArtifactId())) {
       Xpp3Dom configurationNode = (Xpp3Dom) plugin.getConfiguration();
       Xpp3Dom[] instructions = configurationNode.getChildren("instructions");
       if (instructions.length == 1) {
         Xpp3Dom[] exportPackage = instructions[0].getChildren(packagetype);
         if (exportPackage.length == 1) {
           exportedPackagesList.clear(); // clear default configuration (All packages by default)
           String exportpackages = exportPackage[0].getValue();
           if (exportpackages != null) {
             exportedPackagesList.addAll(Arrays.asList(exportpackages.split(",")));
           }
         } else {
           log.warn(
               "Invalid configuration for <Export-Package> entry"
                   + " using default configuration for <Export-Package>");
         }
       } else {
         log.warn(
             "Invalid instructions configuration for plugin : maven-bundle-plugin"
                 + " using default configuration for <Export-Package>");
       }
       break; // not considering multiple versions of the maven-bundle-plugin
     }
   }
   return exportedPackagesList;
 }
Exemple #3
0
	public static File getDependencyPath(URL resource, boolean isRelativePath) {
		if (resource!=null) {
			IPath path = Activator.getDefault().getStateLocation();
			IPath libFolder = path.append("lib");
			String[] paths = resource.getFile().split("/");
			IPath library = libFolder.append(paths[paths.length - 1]);
			File libraryFile = library.toFile();
			if (!libraryFile.exists()) {
				try {
					writeToFile(libraryFile, resource.openStream());
				} catch (IOException e) {
					log.error(e);
					return null;
				}
			}
			if (isRelativePath) {
				IPath relativePath = EclipseUtils
						.getWorkspaceRelativePath(library);
				relativePath = new Path(Constants.ECLIPSE_WORKSPACE_PATH)
						.append(relativePath);
				return relativePath.toFile();
			} else {
				return library.toFile();
			}
		} else{
			log.error("the requested resource does not exist in library path");
			return null;
		}
	}
  /** create dialog area for the user permission dialog */
  protected Control createDialogArea(final Composite parent) {
    parent
        .getShell()
        .setText(
            "Permissions for "
                + regResourceNode.getConnectionInfo().getUrl().toString()
                + regResourceNode.getRegistryResourcePath());

    GridLayout gridLayout = new GridLayout(1, true);
    gridLayout.marginWidth = 5;
    parent.setLayout(gridLayout);

    Group group = new Group(parent, SWT.FILL);
    group.setLayoutData(new GridData(GridData.FILL_BOTH));
    gridLayout = new GridLayout(1, true);
    group.setLayout(gridLayout);

    createTable(group);
    try {
      loadData();
    } catch (RemoteException e) {
      log.error(e);
    } catch (Exception e) {
      log.error(e);
    }

    return super.createDialogArea(parent);
  }
  public static ESBArtifact getESBArtifactFromFile(
      IFile refactoredFile, String projectNatureFilter) {
    IProject esbProject = refactoredFile.getProject();
    try {
      esbProject.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());

      if (esbProject.isOpen() && esbProject.hasNature(projectNatureFilter)) {

        ESBProjectArtifact esbProjectArtifact = new ESBProjectArtifact();
        esbProjectArtifact.fromFile(esbProject.getFile("artifact.xml").getLocation().toFile());
        List<ESBArtifact> allESBArtifacts = esbProjectArtifact.getAllESBArtifacts();

        String originalFileRelativePath =
            FileUtils.getRelativePath(
                    esbProject.getLocation().toFile(), refactoredFile.getLocation().toFile())
                .replaceAll(Pattern.quote(File.separator), "/");

        for (ESBArtifact esbArtifact : allESBArtifacts) {
          if (esbArtifact.getFile().equals(originalFileRelativePath)) {
            return esbArtifact;
          }
        }
      }
    } catch (CoreException e) {
      log.error("Error while reading ESB Project", e);
    } catch (FactoryConfigurationError e) {
      log.error("Error while reading ESB Project", e);
    } catch (Exception e) {
      log.error("Error while reading ESB Project", e);
    }

    return null;
  }
 public boolean performFinish() {
   String source = detailWizardPage.getCloudConnectorPath();
   try {
     ZipFile zipFile = new ZipFile(source);
     String[] segments = source.split(Pattern.quote(File.separator));
     String zipFileName = segments[segments.length - 1].split(".zip")[0];
     // String destination =
     // detailWizardPage.getSelectedProject().getLocation().toOSString()+File.separator+"cloudConnectors"+File.separator+zipFileName;
     String destination =
         detailWizardPage.getSelectedProject().getWorkspace().getRoot().getLocation().toString()
             + File.separator
             + DIR_DOT_METADATA
             + File.separator
             + DIR_CONNECTORS
             + File.separator
             + zipFileName;
     zipFile.getFile();
     zipFile.extractAll(destination);
     IUpdateGMFPlugin updateGMFPlugin = GMFPluginDetails.getiUpdateGMFPlugin();
     if (updateGMFPlugin != null) {
       updateGMFPlugin.updateOpenedEditors();
     }
     /*
      * Refresh the project.
      */
     detailWizardPage.getSelectedProject().refreshLocal(IResource.DEPTH_INFINITE, null);
   } catch (ZipException e) {
     log.error("Error while extracting the connector zip", e);
   } catch (CoreException e) {
     log.error("Cannot refresh the project", e);
   }
   return true;
 }
  /**
   * Install selected features in to developer studio. Note: call {@link
   * #setSelectedFeaturesToInstall(List) setSelectedFeaturesToInstall} first.
   *
   * @param monitor
   */
  public void installSelectedFeatures(IProgressMonitor monitor) {
    SubMonitor progress = SubMonitor.convert(monitor, Messages.UpdateManager_32, 2);

    URI[] repos = new URI[] {getDevStudioReleaseSite()};
    session = new ProvisioningSession(p2Agent);
    installOperation = new InstallOperation(session, selectedFeatures);
    installOperation.getProvisioningContext().setArtifactRepositories(repos);
    installOperation.getProvisioningContext().setMetadataRepositories(repos);
    IStatus status = installOperation.resolveModal(progress.newChild(1));
    if (status.getSeverity() == IStatus.CANCEL || progress.isCanceled()) {
      throw new OperationCanceledException();
    } else if (status.getSeverity() == IStatus.ERROR) {
      String message = status.getChildren()[0].getMessage();
      log.error(Messages.UpdateManager_33 + message);
    } else {
      ProvisioningJob provisioningJob = installOperation.getProvisioningJob(progress.newChild(1));
      if (provisioningJob != null) {
        provisioningJob.addJobChangeListener(
            new JobChangeAdapter() {
              @Override
              public void done(IJobChangeEvent arg0) {
                Display.getDefault()
                    .syncExec(
                        new Runnable() {
                          @Override
                          public void run() {
                            boolean restart =
                                MessageDialog.openQuestion(
                                    Display.getDefault().getActiveShell(),
                                    Messages.UpdateManager_34,
                                    Messages.UpdateManager_35 + Messages.UpdateManager_36);
                            if (restart) {
                              PlatformUI.getWorkbench().restart();
                            }
                          }
                        });
              }
            });
        provisioningJob.schedule();
        Display.getDefault()
            .syncExec(
                new Runnable() {
                  @Override
                  public void run() {
                    try {
                      PlatformUI.getWorkbench()
                          .getActiveWorkbenchWindow()
                          .getActivePage()
                          .showView(IProgressConstants.PROGRESS_VIEW_ID);
                    } catch (PartInitException e) {
                      log.error(e);
                    }
                  }
                });
      } else {
        log.error(Messages.UpdateManager_37);
      }
    }
  }
  /**
   * Finds available WSO2 features in current profile and search for updates to them in WSO2 p2
   * repository for updates.
   *
   * @param monitor
   * @throws Exception
   */
  public void checkForAvailableUpdates(IProgressMonitor monitor) throws Exception {
    if (monitor == null) {
      monitor = new NullProgressMonitor();
    }
    SubMonitor progress = SubMonitor.convert(monitor, Messages.UpdateManager_18, 6);

    // get all available IUs in update repository
    IMetadataRepository metadataRepo =
        metadataRepoManager.loadRepository(getDevStudioUpdateSite(), progress.newChild(1));
    IQuery<IInstallableUnit> allIUQuery = QueryUtil.createIUAnyQuery();
    IQueryResult<IInstallableUnit> allIUQueryResult =
        metadataRepo.query(allIUQuery, progress.newChild(1));

    // read artifact repository for updates
    IArtifactRepository artifactRepo =
        artifactRepoManager.loadRepository(getDevStudioUpdateSite(), progress.newChild(1));

    // read meta-data of all available features
    Map<String, EnhancedFeature> allFeaturesInUpdateRepo =
        loadWSO2FeaturesInRepo(artifactRepo, allIUQueryResult, progress.newChild(1));

    // get all installed wso2 features
    Collection<IInstallableUnit> installedWSO2Features =
        getInstalledWSO2Features(progress.newChild(1));

    installedWSO2FeaturesMap = new HashMap<String, IInstallableUnit>();
    for (IInstallableUnit iInstallableUnit : installedWSO2Features) {
      installedWSO2FeaturesMap.put(iInstallableUnit.getId(), iInstallableUnit);
    }

    if (progress.isCanceled()) {
      throw new OperationCanceledException();
    }

    URI[] repos = new URI[] {getDevStudioUpdateSite()};
    updateOperation = new UpdateOperation(session, installedWSO2Features);
    updateOperation.getProvisioningContext().setArtifactRepositories(repos);
    updateOperation.getProvisioningContext().setMetadataRepositories(repos);

    // resolve update operation
    IStatus status = updateOperation.resolveModal(progress.newChild(1));
    // user cancelled the job while resolving
    if (status.getSeverity() == IStatus.CANCEL || progress.isCanceled()) {
      throw new OperationCanceledException();
    }
    // there is nothing to update
    if (status.getCode() == UpdateOperation.STATUS_NOTHING_TO_UPDATE) {
      featuresWithPossibleUpdates = new HashMap<String, EnhancedFeature>();
      log.info(Messages.UpdateManager_19);
    } else if (status.getSeverity() == IStatus.ERROR) { // resolution errors
      // something wrong with the updates
      log.info(Messages.UpdateManager_20);
    } else {
      // good to proceed installing updates
      setPossibleUpdates(updateOperation.getPossibleUpdates(), allFeaturesInUpdateRepo);
    }
  }
 public static boolean waitForServerToChangeState(
     IServer server, Shell shell, int changeStateFrom, int changeStateTo, String msg) {
   ProgressMonitorDialog progressMonitorDialog = new ProgressMonitorDialog(shell);
   CarbonServerStateChange serverStateChange =
       new CarbonServerStateChange(server, changeStateFrom, changeStateTo, 180000, msg);
   progressMonitorDialog.setBlockOnOpen(false);
   try {
     progressMonitorDialog.run(true, true, serverStateChange);
     return progressMonitorDialog.getReturnCode() != ProgressMonitorDialog.CANCEL;
   } catch (InvocationTargetException e) {
     log.error(e);
   } catch (InterruptedException e) {
     log.error(e);
   }
   return false;
 }
  protected void addPages() {
    editorPage =
        new RegistryInfoEditorPage(
            this,
            "org.wso2.developerstudio.eclipse.artifact.registry.handler.editor.design",
            "Design");
    sourceEditor = new StructuredTextEditor();
    sourceEditor.setEditorPart(this);
    try {
      editorPage.initContent();
      formEditorIndex = addPage(editorPage);
      sourceEditorIndex = addPage(sourceEditor, getEditorInput());
      setPageText(sourceEditorIndex, "Source");

      getDocument()
          .addDocumentListener(
              new IDocumentListener() {

                public void documentAboutToBeChanged(final DocumentEvent event) {
                  // nothing to do
                }

                public void documentChanged(final DocumentEvent event) {
                  sourceDirty = true;
                  updateDirtyState();
                }
              });
    } catch (Exception e) {
      log.error(e);
    }
  }
 public void openEditor(File file) {
   try {
     refreshDistProjects();
     OMElement documentElement = new StAXOMBuilder(new FileInputStream(file)).getDocumentElement();
     OMElement firstElement = documentElement.getFirstElement();
     String templateType = "template.sequence";
     if ("endpoint".equals(firstElement.getLocalName())) {
       templateType = "template.endpoint";
       String localName = firstElement.getFirstElement().getLocalName();
       if ("address".equals(localName)) {
         templateType = templateType + "-1";
       } else if ("wsdl".equals(localName)) {
         templateType = templateType + "-2";
       } else {
         templateType = templateType + "-0";
       }
     }
     IFile dbsFile =
         ResourcesPlugin.getWorkspace()
             .getRoot()
             .getFileForLocation(Path.fromOSString(file.getAbsolutePath()));
     String path = dbsFile.getParent().getFullPath() + "/";
     String source = FileUtils.getContentAsString(file);
     Openable openable = ESBGraphicalEditor.getOpenable();
     openable.editorOpen(file.getName(), templateType, path + "template_", source);
   } catch (Exception e) {
     log.error("Cannot open the editor", e);
   }
 }
 public static MavenProject getMavenProject(IProject project) {
   try {
     return MavenUtils.getMavenProject(project.getFile("pom.xml").getLocation().toFile());
   } catch (Exception e) {
     log.error("Failed to retrive the maven project for the given project", e);
   }
   return null;
 }
  public void run() {
    try {
      LoginAction loginAction = new LoginAction();
      loginAction.login(true, true);

    } catch (Exception e) {
      log.error("Cannot open AppFactory perspective", e);
    }
  }
 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 boolean canFlipToNextPage() {
   selectedIemList = changePermissionWizPage1.selectedItemList();
   fillTextArea(selectedIemList);
   try {
     setAssignedPermissionsToRole();
   } catch (Exception e) {
     log.error(e);
   }
   return false;
 }
 public static void serverRemoved(IServer server) {
   if (getServers().contains(server)) {
     try {
       cleanupServerConfigurations(server);
     } catch (Exception e) {
       log.error(e);
     }
     getServers().remove(server);
     if (getAppServerInformation().containsKey(server)) getAppServerInformation().remove(server);
   }
 }
 private URI getDevStudioReleaseSite() {
   URI releaseSite = null;
   try {
     IPreferenceStore preferenceStore =
         org.wso2.developerstudio.eclipse.platform.ui.Activator.getDefault().getPreferenceStore();
     String url = preferenceStore.getString(UpdateCheckerPreferencePage.RELESE_SITE_URL);
     releaseSite = new URI(url);
   } catch (URISyntaxException e) {
     log.error(e);
   }
   return releaseSite;
 }
 public boolean performFinish() {
   try {
     project = templateModel.getTemplateSaveLocation().getProject();
     createSequenceArtifact(templateModel);
     if (fileLst.size() > 0) {
       openEditor(fileLst.get(0));
     }
   } catch (Exception e) {
     log.error("An unexpected error has occurred", e);
   }
   return true;
 }
  /** For a given Zip file, process each entry. */
  public static void unZip(String fileName) {

    createdDirs = new TreeSet();
    try {
      zipFile = new ZipFile(fileName);
      Enumeration all = zipFile.entries();
      while (all.hasMoreElements()) {
        unzipFile((ZipEntry) all.nextElement());
      }
    } catch (IOException e) {
      log.error(e);
    }
  }
  /*
   * (non-Javadoc)
   * Initializes the editor part with a site and input.
   */
  public void init(IEditorSite site, IEditorInput input) {
    super.init(site, input);

    GenericServer gserver = (GenericServer) server.getOriginal().getAdapter(GenericServer.class);
    try {
      gserver.getServerInstanceProperties();
      int a = 10;
    } catch (Exception e) {
      log.error(e);
    }
    addChangeListener();
    initialize();
  }
 private int getPortfromTransportXML(String protocolType) {
   int port = 0;
   String transportsXmlPath = getTransportXmlFilePath();
   XPathFactory factory = XPathFactory.newInstance();
   File xmlDocument = new File(transportsXmlPath);
   try {
     InputSource inputSource = new InputSource(new FileInputStream(xmlDocument));
     XPath xPath = factory.newXPath();
     XPathExpression xPathExpression =
         xPath.compile(
             "/transports/transport[@name='" + protocolType + "']/parameter[@name='port']");
     String evaluate = xPathExpression.evaluate(inputSource);
     port = Integer.parseInt(evaluate);
   } catch (NumberFormatException e) {
     log.error(e);
   } catch (FileNotFoundException e) {
     log.error(e);
   } catch (XPathExpressionException e) {
     log.error(e);
   }
   return port;
 }
  public List<ListData> getListData(String modelProperty, ProjectDataModel model) {

    List<ListData> list = new ArrayList<ListData>();

    IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
    final String EXTENSIONPOINT_ID = "org.wso2.developerstudio.eclipse.capp.artifacts.provider";
    IConfigurationElement[] config =
        Platform.getExtensionRegistry().getConfigurationElementsFor(EXTENSIONPOINT_ID);

    for (IConfigurationElement element : config) {
      Object obj = null;
      try {
        obj = element.createExecutableExtension("class");
      } catch (CoreException ex) {
        log.error("Error executing CappArtifactsListProvider extension ", ex);
      }

      if (obj instanceof CappArtifactsListProvider) {

        CappArtifactsListProvider provider = (CappArtifactsListProvider) obj;
        String nature = element.getAttribute("nature");
        for (IProject project : projects) {
          try {
            if (project.isOpen() && project.hasNature(nature)) {
              List<ListData> listReceivedFromprovider = null;
              listReceivedFromprovider = provider.getArtifactsListForCappExport(project);
              list.addAll(listReceivedFromprovider);
            }
          } catch (Exception e) {
            log.error("Error getting artifacts from extension", e);
          }
        }
      }
    }

    return list;
  }
Exemple #23
0
 /** save newly added registry url to the url file */
 private void saveUrlsToFile() {
   if (urlListFile.exists()) {
     urlListFile.delete();
   }
   if (!urlListFile.getParentFile().exists()) {
     urlListFile.getParentFile().mkdirs();
   }
   Writer output = null;
   try {
     output = new BufferedWriter(new FileWriter(urlListFile));
     for (RegistryURLInfo registryURLInfo : urlList) {
       try {
         output.write(
             registryURLInfo.getUrl().toString()
                 + " "
                 + Boolean.toString(registryURLInfo.isEnabled())
                 + " "
                 + registryURLInfo.getUsername()
                 + " "
                 + registryURLInfo.getPath()
                 + "\n");
       } catch (IOException e) {
         log.error(e);
       }
     }
   } catch (IOException e) {
     log.error(e);
   } finally {
     if (output != null)
       try {
         output.close();
       } catch (IOException e) {
         log.error(e);
       }
   }
 }
  protected void okPressed() {
    Object selectedElement = getSelectedElement();
    IDeveloperStudioElement resource = (IDeveloperStudioElement) selectedElement;

    /*
    if (resource.getSource() instanceof IFile) {
    	IFile selectedIFile = (IFile) resource.getSource();
    	ipathOfselection = selectedIFile.getFullPath().toString();

    	IProject project = selectedIFile.getProject();
    	RegistryFileImpl rpi = (RegistryFileImpl)selectedElement;
    	String fileName = rpi.getName();
    	String fullPath = rpi.getPath();
    	int index = fullPath.lastIndexOf('/');
    	String path = "";
    	if (index > 0) {
    		path = fullPath.substring(0,index);
    	}

    	if (path != null && !path.isEmpty())
    		try {
    			CreateNewConfigurationDialog.createRegistryResourcesForInputScemaAndOutputSchema(fileName, project, path);
    		} catch (Exception e) {
    			log.error(e.getMessage());
    		}
    }
    */

    if (showOpenResourceCheckBox && chkOpenResource.getSelection()) {
      try {
        if (resource.getSource() instanceof IFile) {
          IDE.openEditor(
              PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(),
              (IFile) resource.getSource());
        } else if (resource.getSource() instanceof File && ((File) resource.getSource()).isFile()) {
          IFileStore fileStore =
              EFS.getLocalFileSystem().getStore(((File) resource.getSource()).toURI());
          IWorkbenchPage page =
              PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
          IDE.openEditorOnFileStore(page, fileStore);
        }
      } catch (PartInitException e) {
        log.error("Error opening the resource file", e);
      }
    }
    super.okPressed();
  }
 public boolean unpublishServiceModule(String serverId, String webTempPath, String projectName) {
   IServer server = getServer(serverId);
   IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
   CarbonServerManager wsasServerManager = this;
   HashMap<String, Object> operationParameters = new HashMap<String, Object>();
   operationParameters.put(
       ICarbonOperationManager.PARAMETER_TYPE, ICarbonOperationManager.OPERATION_UNPUBLISH_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;
   }
 }
  protected void addServletTransportPorts(List<Integer> ports, String carbonXmlPath) {
    int port = 0;
    XPathFactory factory = XPathFactory.newInstance();
    NamespaceContext cntx = CarbonServer32Utils.getCarbonNamespace();
    File xmlDocument = new File(carbonXmlPath);
    try {
      InputSource inputSource = new InputSource(new FileInputStream(xmlDocument));
      DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
      Document document = builder.parse(xmlDocument);
      XPath xPath = factory.newXPath();
      xPath.setNamespaceContext(cntx);

      int offSet =
          Integer.parseInt(
              (String) xPath.evaluate("/Server/Ports/Offset", document, XPathConstants.STRING));
      String evaluate =
          (String)
              xPath.evaluate(
                  "/Server/Ports/ServletTransports/HTTPS", document, XPathConstants.STRING);

      if (!evaluate.equals("")) {
        port = Integer.parseInt(evaluate) + offSet;
      } else {
        port = getPortfromTransportXML("https");
      }
      ports.add(port);
      inputSource = new InputSource(new FileInputStream(xmlDocument));
      evaluate =
          (String)
              xPath.evaluate(
                  "/Server/Ports/ServletTransports/HTTP", document, XPathConstants.STRING);

      if (!evaluate.equals("")) {
        port = Integer.parseInt(evaluate) + offSet;
      } else {
        port = getPortfromTransportXML("http");
      }
      ports.add(port);

    } catch (NumberFormatException e) {
      log.error(e);
    } catch (FileNotFoundException e) {
      log.error(e);
    } catch (XPathExpressionException e) {
      log.error(e);
    } catch (ParserConfigurationException e) {
      log.error(e);
    } catch (SAXException e) {
      log.error(e);
    } catch (IOException e) {
      log.error(e);
    }
  }
 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 void openEditor(File file) {
    try {
      refreshDistProjects();
      OMElement documentElement = new StAXOMBuilder(new FileInputStream(file)).getDocumentElement();
      String templateType = "";

      if (documentElement.getChildrenWithName(new QName("endpoint")) != null
          && documentElement.getChildrenWithName(new QName("endpoint")).hasNext()) {
        // Endpoint template.
        templateType = ArtifactType.TEMPLATE_ENDPOINT.getLiteral();
        OMElement endpoint =
            (OMElement) documentElement.getChildrenWithName(new QName("endpoint")).next();
        String localName = endpoint.getFirstElement().getLocalName();
        if ("address".equals(localName)) {
          // Address endpoint template.
          templateType = ArtifactType.TEMPLATE_ENDPOINT_ADDRESS.getLiteral();
        } else if ("wsdl".equals(localName)) {
          // WSDL endpoint template.
          templateType = ArtifactType.TEMPLATE_ENDPOINT_WSDL.getLiteral();
        } else if ("http".equals(localName)) {
          // HTTP endpoint template.
          templateType = ArtifactType.TEMPLATE_ENDPOINT_HTTP.getLiteral();
        } else {
          // Default endpoint template.
          templateType = ArtifactType.TEMPLATE_ENDPOINT_DEFAULT.getLiteral();
        }
      } else {
        // Sequence template.
        templateType = ArtifactType.TEMPLATE_SEQUENCE.getLiteral();
      }

      IFile dbsFile =
          ResourcesPlugin.getWorkspace()
              .getRoot()
              .getFileForLocation(Path.fromOSString(file.getAbsolutePath()));
      String path = dbsFile.getParent().getFullPath() + "/";
      String source = FileUtils.getContentAsString(file);
      Openable openable = ESBGraphicalEditor.getOpenable();
      openable.editorOpen(file.getName(), templateType, path, source);
    } catch (Exception e) {
      log.error("Cannot open the editor", e);
    }
  }
  public boolean hotUpdateWebApp(String serverId, IResource resource, String projectName) {

    IServer server = getServer(serverId);
    IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
    CarbonServerManager wsasServerManager = this;
    HashMap<String, Object> operationParameters = new HashMap<String, Object>();
    operationParameters.put(
        ICarbonOperationManager.PARAMETER_TYPE,
        ICarbonOperationManager.OPERATION_HOT_UPDATE_MODULE);
    operationParameters.put(ICarbonOperationManager.PARAMETER_WebTempPath, "");
    operationParameters.put(ICarbonOperationManager.PARAMETER_PROJECT, project);
    operationParameters.put(RESOURCE, resource);
    operationParameters.put(RESOURCE_CHANGE_KIND, new Integer(resourceChngeKind));
    try {
      wsasServerManager.executeOperationOnServer(server, operationParameters);
      return true;
    } catch (Exception e) {
      log.error(e);
      return false;
    }
  }
  public static IPath getServerHome(IServer server) {
    IPath location = null;
    if (server != null) {
      IServerManager wsasServerManager = getInstance();
      HashMap<String, Object> operationParameters = new HashMap<String, Object>();
      operationParameters.put(
          ICarbonOperationManager.PARAMETER_TYPE,
          ICarbonOperationManager.OPERATION_GET_SERVER_HOME);
      Object r;
      try {
        r = wsasServerManager.executeOperationOnServer(server, operationParameters);
        if (r instanceof IPath) location = (IPath) r;
      } catch (NoSuchCarbonOperationDefinedException e) {
        return null;
      } catch (Exception e) {
        log.error(e);
      }
    }

    return location;
  }