/**
   * Method "replace".
   *
   * @return true if ok
   */
  public boolean replace(String migrationTaskName) {
    IFolder librariesFolder = ResourceManager.getLibrariesFolder();
    IFile definitionFile = librariesFolder.getFile(TALENDDEFINITIONFILENAME);

    if (definitionFile.exists()) {
      File file = new File(definitionFile.getLocationURI());
      try {
        String content = FileUtils.readFileToString(file, EMFUtil.ENCODING);
        for (String oldString : old2new.keySet()) {
          String newString = old2new.get(oldString);
          if (log.isInfoEnabled()) {
            log.info(
                DefaultMessagesImpl.getString(
                    "TalendDefinitionFileUpdate_MigLog",
                    migrationTaskName,
                    oldString,
                    newString)); //$NON-NLS-1$
          }
          content = StringUtils.replace(content, oldString, newString);
        }
        FileUtils.writeStringToFile(file, content, EMFUtil.ENCODING);
      } catch (IOException e) {
        log.error(e.getMessage(), e);
        return false;
      }
    }

    return true;
  }
 /**
  * DOC xqliu Comment method "importFromExchange".
  *
  * @param componet
  * @return
  */
 public static void importFromExchange(IEcosComponent componet) throws Exception {
   File file = new File(componet.getInstalledLocation());
   File copiedFile =
       new File(
           System.getProperty("java.io.tmpdir")
               + File.separator
               + new Path(componet.getInstalledLocation()).lastSegment()); // $NON-NLS-1$
   FileUtils.copyFile(file, copiedFile); // copy the downloaded file out of the workspace
   Wizard wizard = new ImportFromExchangeWizard(copiedFile.getAbsolutePath());
   WizardDialog dialog = new WizardDialog(null, wizard);
   if (WizardDialog.OK == dialog.open()) {
     ResourceManager.getLibrariesFolder().refreshLocal(IResource.DEPTH_INFINITE, null);
   }
 }
  /**
   * Method "indexOf".
   *
   * @return the index of the first occurrence of the character in the character sequence
   *     represented by this object, or <code>-1</code> if the character does not occur.
   */
  public int indexOf(String str) {
    IFolder librariesFolder = ResourceManager.getLibrariesFolder();
    IFile definitionFile = librariesFolder.getFile(TALENDDEFINITIONFILENAME);

    if (definitionFile.exists()) {
      File file = new File(definitionFile.getLocationURI());
      try {
        String content = FileUtils.readFileToString(file, EMFUtil.ENCODING);
        return content.indexOf(str);
      } catch (IOException e) {
        log.error(e.getMessage(), e);
        return -1;
      }
    }
    return -1;
  }