static void logPlugins() {
    List<String> loadedBundled = new ArrayList<String>();
    List<String> disabled = new ArrayList<String>();
    List<String> loadedCustom = new ArrayList<String>();

    for (IdeaPluginDescriptor descriptor : ourPlugins) {
      final String version = descriptor.getVersion();
      String s = descriptor.getName() + (version != null ? " (" + version + ")" : "");
      if (descriptor.isEnabled()) {
        if (descriptor.isBundled() || SPECIAL_IDEA_PLUGIN.equals(descriptor.getName()))
          loadedBundled.add(s);
        else loadedCustom.add(s);
      } else {
        disabled.add(s);
      }
    }

    Collections.sort(loadedBundled);
    Collections.sort(loadedCustom);
    Collections.sort(disabled);

    getLogger().info("Loaded bundled plugins: " + StringUtil.join(loadedBundled, ", "));
    if (!loadedCustom.isEmpty()) {
      getLogger().info("Loaded custom plugins: " + StringUtil.join(loadedCustom, ", "));
    }
    if (!disabled.isEmpty()) {
      getLogger().info("Disabled plugins: " + StringUtil.join(disabled, ", "));
    }
  }
  /* 接続している全員にmessageを送信するメソッド  『POST』*/
  public void post(String message) throws IOException {
    int flag1 = 1; // フラグ(送信者表示時に利用)

    System.out.println(message);
    List names = new ArrayList(); // 送信者リストを作る

    // チャットに参加しているユーザ全員にメッセージを送信する

    for (int i = 0; i < clients.size(); i++) {
      ChatClientHandler handler = (ChatClientHandler) clients.get(i);
      if (handler != this) { // 自分以外のユーザで
        names.add(handler.getClientName()); // 送信者リストに名前追加
        handler.send("[" + this.getClientName() + "]" + message); // メッセージを送信
      }
    }

    Collections.sort(names); // 送信者リストをソート

    String returnMessage = ""; // 初期化

    for (int i = 0; i < names.size(); i++) { //
      if (flag1 == 0) // 2人目以降、前に「,」つける
      returnMessage = returnMessage + ",";
      returnMessage = returnMessage + names.get(i); // 送信者リストに名前を追加
      flag1 = 0; // 2人目以降フラグをおろす
    }
    this.send("<< To. " + returnMessage + ">>");
  }
  public boolean perform(
      String[] strings,
      List clients,
      List rejectList,
      Map groups,
      ChatClientHandler_345387 myHandler)
      throws IOException {
    // ユーザの名前を入れてソートするためのListを宣言(ローカル変数)
    List names = new ArrayList();

    // 全クライアントのListに加える
    for (int i = 0; i < clients.size(); i++) {
      ChatClientHandler_345387 handler = (ChatClientHandler_345387) clients.get(i);
      names.add(handler.getClientName());
    }

    // ソートする
    Collections.sort(names);

    // 接続中のクライアント名をコンマで区切って昇順に一行で表示
    String returnMessage = "";
    for (int i = 0; i < names.size(); i++) {
      returnMessage += names.get(i) + ",";
    }
    myHandler.send(returnMessage);

    System.out.println(myHandler.getClientName() + ": users: " + returnMessage);

    return true;
  }
Beispiel #4
0
 public void addTick(Cam c) {
   tickArr.add(new Tick(hs1.getSliderPos(), hsYPos, c, hs1.getPosInSeconds()));
   // set the older ticks to inactive
   for (int i = 0; i < tickArr.size() - 1; i++) {
     tickArr.get(i).setToInActive();
   }
   // sort the ticks in case one was placed before an existing tick
   Collections.sort(tickArr);
 }
Beispiel #5
0
  public String _sort(String args[]) {
    verifyCommand(args, _sortHelp, null, 2, Integer.MAX_VALUE);

    List<String> result = new ArrayList<String>();
    for (int i = 1; i < args.length; i++) {
      Processor.split(args[i], result);
    }
    Collections.sort(result);
    return Processor.join(result);
  }
Beispiel #6
0
 /**
  * Gets the list of the vnmrj users(operators) for the current unix user logged in
  *
  * @return the list of vnmrj users
  */
 protected Object[] getOperators() {
   String strUser = System.getProperty("user.name");
   User user = LoginService.getDefault().getUser(strUser);
   ArrayList<String> aListOperators = user.getOperators();
   if (aListOperators == null || aListOperators.isEmpty())
     aListOperators = new ArrayList<String>();
   Collections.sort(aListOperators);
   if (aListOperators.contains(strUser)) aListOperators.remove(strUser);
   aListOperators.add(0, strUser);
   return (aListOperators.toArray());
 }
Beispiel #7
0
  /**
   * Unchoke connected peers.
   *
   * <p>This is one of the "clever" places of the BitTorrent client. Every
   * OPTIMISTIC_UNCHOKING_FREQUENCY seconds, we decide which peers should be unchocked and
   * authorized to grab pieces from us.
   *
   * <p>Reciprocation (tit-for-tat) and upload capping is implemented here by carefully choosing
   * which peers we unchoke, and which peers we choke.
   *
   * <p>The four peers with the best download rate and are interested in us get unchoked. This
   * maximizes our download rate as we'll be able to get data from there four "best" peers quickly,
   * while allowing these peers to download from us and thus reciprocate their generosity.
   *
   * <p>Peers that have a better download rate than these four downloaders but are not interested
   * get unchoked too, we want to be able to download from them to get more data more quickly. If
   * one becomes interested, it takes a downloader's place as one of the four top downloaders (i.e.
   * we choke the downloader with the worst upload rate).
   *
   * @param optimistic Whether to perform an optimistic unchoke as well.
   */
  private synchronized void unchokePeers(boolean optimistic) {
    // Build a set of all connected peers, we don't care about peers we're
    // not connected to.
    List<SharingPeer> bound = new ArrayList<SharingPeer>(getConnectedPeers());
    Collections.sort(bound, this.getPeerRateComparator());
    Collections.reverse(bound);

    if (bound.size() == 0) {
      logger.trace("No connected peers, skipping unchoking.");
      return;
    } else {
      logger.trace("Running unchokePeers() on {} connected peers.", bound.size());
    }

    int downloaders = 0;
    Set<SharingPeer> choked = new HashSet<SharingPeer>();

    // We're interested in the top downloaders first, so use a descending
    // set.
    for (SharingPeer peer : bound) {
      if (downloaders < Client.MAX_DOWNLOADERS_UNCHOKE) {
        // Unchoke up to MAX_DOWNLOADERS_UNCHOKE interested peers
        if (peer.isChoking()) {
          if (peer.isInterested()) {
            downloaders++;
          }

          peer.unchoke();
        }
        continue;
      }
      // Choke everybody else
      choked.add(peer);
    }

    // Actually choke all chosen peers (if any), except the eventual
    // optimistic unchoke.
    if (choked.size() > 0) {
      SharingPeer randomPeer =
          choked.toArray(new SharingPeer[0])[this.random.nextInt(choked.size())];

      for (SharingPeer peer : choked) {
        if (optimistic && peer == randomPeer) {
          logger.debug("Optimistic unchoke of {}.", peer);
          continue;
        }

        peer.choke();
      }
    }
  }
  private void updateList() {
    ActionSet actionSet = (ActionSet) combo.getSelectedItem();
    EditAction[] actions = actionSet.getActions();
    Vector listModel = new Vector(actions.length);

    for (int i = 0; i < actions.length; i++) {
      EditAction action = actions[i];
      String label = action.getLabel();
      if (label == null) continue;

      listModel.addElement(new ToolBarOptionPane.Button(action.getName(), null, null, label));
    }

    Collections.sort(listModel, new ToolBarOptionPane.ButtonCompare());
    list.setListData(listModel);
  }
  /**
   * @param fld Folder with files to match.
   * @param ptrn Pattern to match against file name.
   * @return Collection of matched files.
   */
  public static List<VisorLogFile> matchedFiles(File fld, final String ptrn) {
    List<VisorLogFile> files =
        fileTree(
            fld,
            MAX_FOLDER_DEPTH,
            new FileFilter() {
              @Override
              public boolean accept(File f) {
                return !f.isHidden()
                    && (f.isDirectory() || f.isFile() && f.getName().matches(ptrn));
              }
            });

    Collections.sort(files, LAST_MODIFIED);

    return files;
  }
  private static Graph<PluginId> createPluginIdGraph(
      final Map<PluginId, IdeaPluginDescriptorImpl> idToDescriptorMap) {
    final List<PluginId> ids = new ArrayList<PluginId>(idToDescriptorMap.keySet());
    // this magic ensures that the dependent plugins always follow their dependencies in
    // lexicographic order
    // needed to make sure that extensions are always in the same order
    Collections.sort(
        ids,
        new Comparator<PluginId>() {
          @Override
          public int compare(PluginId o1, PluginId o2) {
            return o2.getIdString().compareTo(o1.getIdString());
          }
        });
    return GraphGenerator.create(
        CachingSemiGraph.create(
            new GraphGenerator.SemiGraph<PluginId>() {
              @Override
              public Collection<PluginId> getNodes() {
                return ids;
              }

              @Override
              public Iterator<PluginId> getIn(PluginId pluginId) {
                final IdeaPluginDescriptor descriptor = idToDescriptorMap.get(pluginId);
                ArrayList<PluginId> plugins = new ArrayList<PluginId>();
                for (PluginId dependentPluginId : descriptor.getDependentPluginIds()) {
                  // check for missing optional dependency
                  if (idToDescriptorMap.containsKey(dependentPluginId)) {
                    plugins.add(dependentPluginId);
                  }
                }
                return plugins.iterator();
              }
            }));
  }
  static void initializePlugins(@Nullable StartupProgress progress) {
    configureExtensions();

    final IdeaPluginDescriptorImpl[] pluginDescriptors = loadDescriptors(progress);

    final Class callerClass = ReflectionUtil.findCallerClass(1);
    assert callerClass != null;
    final ClassLoader parentLoader = callerClass.getClassLoader();

    final List<IdeaPluginDescriptorImpl> result = new ArrayList<IdeaPluginDescriptorImpl>();
    final HashMap<String, String> disabledPluginNames = new HashMap<String, String>();
    for (IdeaPluginDescriptorImpl descriptor : pluginDescriptors) {
      if (descriptor.getPluginId().getIdString().equals(CORE_PLUGIN_ID)) {
        final List<String> modules = descriptor.getModules();
        if (modules != null) {
          ourAvailableModules.addAll(modules);
        }
      }

      if (!shouldSkipPlugin(descriptor, pluginDescriptors)) {
        result.add(descriptor);
      } else {
        descriptor.setEnabled(false);
        disabledPluginNames.put(descriptor.getPluginId().getIdString(), descriptor.getName());
        initClassLoader(parentLoader, descriptor);
      }
    }

    prepareLoadingPluginsErrorMessage(filterBadPlugins(result, disabledPluginNames));

    final Map<PluginId, IdeaPluginDescriptorImpl> idToDescriptorMap =
        new HashMap<PluginId, IdeaPluginDescriptorImpl>();
    for (final IdeaPluginDescriptorImpl descriptor : result) {
      idToDescriptorMap.put(descriptor.getPluginId(), descriptor);
    }

    final IdeaPluginDescriptor corePluginDescriptor =
        idToDescriptorMap.get(PluginId.getId(CORE_PLUGIN_ID));
    assert corePluginDescriptor != null
        : CORE_PLUGIN_ID
            + " not found; platform prefix is "
            + System.getProperty(PlatformUtilsCore.PLATFORM_PREFIX_KEY);
    for (IdeaPluginDescriptorImpl descriptor : result) {
      if (descriptor != corePluginDescriptor) {
        descriptor.insertDependency(corePluginDescriptor);
      }
    }

    mergeOptionalConfigs(idToDescriptorMap);

    // sort descriptors according to plugin dependencies
    Collections.sort(result, getPluginDescriptorComparator(idToDescriptorMap));

    for (int i = 0; i < result.size(); i++) {
      ourId2Index.put(result.get(i).getPluginId(), i);
    }

    int i = 0;
    for (final IdeaPluginDescriptorImpl pluginDescriptor : result) {
      if (pluginDescriptor.getPluginId().getIdString().equals(CORE_PLUGIN_ID)
          || pluginDescriptor.isUseCoreClassLoader()) {
        pluginDescriptor.setLoader(parentLoader, true);
      } else {
        final List<File> classPath = pluginDescriptor.getClassPath();
        final PluginId[] dependentPluginIds = pluginDescriptor.getDependentPluginIds();
        final ClassLoader[] parentLoaders = getParentLoaders(idToDescriptorMap, dependentPluginIds);

        final ClassLoader pluginClassLoader =
            createPluginClassLoader(
                classPath.toArray(new File[classPath.size()]),
                parentLoaders.length > 0 ? parentLoaders : new ClassLoader[] {parentLoader},
                pluginDescriptor);
        pluginDescriptor.setLoader(pluginClassLoader, true);
      }

      pluginDescriptor.registerExtensions();
      if (progress != null) {
        progress.showProgress(
            "", PLUGINS_PROGRESS_MAX_VALUE + (i++ / (float) result.size()) * 0.35f);
      }
    }

    ourPlugins = pluginDescriptors;
  }
Beispiel #12
0
  public List getUserTimeSpentByDate(String userObjectId, String startDate, String endDate) {
    List list = new ArrayList();

    log.info("userObjectId=" + userObjectId);
    log.info("startDate=" + startDate);
    log.info("endDate=" + endDate);

    try {

      String apiUrl =
          rallyApiHost
              + "/timeentryvalue?query=((TimeEntryItem.User.ObjectId%20=%20"
              + userObjectId
              + ")"
              + "%20and%20((DateVal%20%3E=%20"
              + startDate
              + ")%20and%20(DateVal%20%3C=%20"
              + endDate
              + ")))"
              + "&start=1&pagesize=100&fetch=true";

      log.info("apiUrl=" + apiUrl);

      String responseXML = getRallyXML(apiUrl);

      log.info("responseXML=" + responseXML);

      org.jdom.input.SAXBuilder bSAX = new org.jdom.input.SAXBuilder();
      org.jdom.Document doc = bSAX.build(new StringReader(responseXML));
      Element root = doc.getRootElement();

      XPath xpath = XPath.newInstance("//Object");
      List xlist = xpath.selectNodes(root);

      Iterator iter = xlist.iterator();
      while (iter.hasNext()) {

        // Map map=new HashMap();

        Element item = (Element) iter.next();

        String hours = item.getChildText("Hours");

        Element timeEntryItemElement = item.getChild("TimeEntryItem");
        String timeEntryItemRef = timeEntryItemElement.getAttributeValue("ref");

        Map map = getUserStoryTaskMap(timeEntryItemRef);

        String checkTaskId = (String) map.get("taskFormattedId");

        boolean isExist = false;
        for (int i = 0; i < list.size(); i++) {
          Map existMap = (Map) list.get(i);

          log.info("existMap=" + existMap);

          String existTaskId = (String) existMap.get("taskFormattedId");

          log.info("existTaskId=" + existTaskId);
          log.info("checkTaskId=" + checkTaskId);

          if (existTaskId != null && existTaskId.equals(checkTaskId)) {
            isExist = true;
            String existHours = (String) existMap.get("hours");
            double eHour = 0.0D;
            if (!"".equals(existHours)) {
              eHour = Double.parseDouble(existHours);
            }
            double nHour = 0.0D;

            if (!"".equals(hours)) {
              nHour = Double.parseDouble(hours);
            }

            log.info("nHour=" + nHour);
            log.info("eHour=" + eHour);

            nHour += eHour;
            log.info("2 nHour=" + nHour);
            existMap.put("hours", "" + nHour);

            break;
          }
        }

        if (!isExist) {
          map.put("hours", hours);
          list.add(map);
        }

        log.info("hours=" + hours);
        log.info("timeEntryItemRef=" + timeEntryItemRef);

        // list.add(map);

      }

      Collections.sort(
          list,
          new Comparator<Map<String, String>>() {
            public int compare(Map<String, String> m1, Map<String, String> m2) {
              if (m1.get("projectName") == null || m2.get("projectName") == null) return -1;
              return m1.get("projectName").compareTo(m2.get("projectName"));
            }
          });

      // Sum up the total time
      double totalTaskEstimate = 0.0D;
      double totalTaskRemaining = 0.0D;
      double totalHours = 0.0D;
      for (int i = 0; i < list.size(); i++) {
        Map map = (Map) list.get(i);

        log.info("taskEstimate=" + (String) map.get("taskEstimate"));
        log.info("taskRemaining=" + (String) map.get("taskRemaining"));
        log.info("hours=" + (String) map.get("hours"));

        log.info("map==" + map);

        try {
          double taskEstimate = Double.parseDouble((String) map.get("taskEstimate"));
          double taskRemaining = Double.parseDouble((String) map.get("taskRemaining"));
          double hours = Double.parseDouble((String) map.get("hours"));

          totalTaskEstimate += taskEstimate;
          totalTaskRemaining += taskRemaining;
          totalHours += hours;
        } catch (Exception e) {
          log.info("ERROR in parsing number" + e);
        }
      }

      Map firstMap = new HashMap();

      firstMap.put("taskFormattedId", "");
      firstMap.put("taskName", "");
      firstMap.put("taskState", "");
      firstMap.put("owner", "");
      firstMap.put("taskEstimate", "" + totalTaskEstimate);
      firstMap.put("taskRemaining", "" + totalTaskRemaining);
      firstMap.put("hours", "" + totalHours);
      firstMap.put("projectName", "");
      firstMap.put("iterationName", "");

      list.add(0, firstMap);

    } catch (Exception ex) {
      log.error("", ex);
    }

    return list;
  }
  public boolean perform(
      String[] strings,
      List clients,
      List rejectList,
      Map groups,
      ChatClientHandler_345387 myHandler)
      throws IOException {

    // 引数なし reject
    if (strings.length == 1) {
      // 拒否リストに居るユーザの名前一覧
      List names = new ArrayList();

      // 自分の現在の拒否リストから順番に名前を names リストに追加する。
      for (int i = 0; i < rejectList.size(); i++) {
        ChatClientHandler_345387 rejHandler = (ChatClientHandler_345387) rejectList.get(i);
        names.add(rejHandler.getClientName());
      }

      // names リストをソートして、自分に拒否リストの一覧を送る。
      String returnMessage = "";
      Collections.sort(names);
      for (int i = 0; i < names.size(); i++) {
        returnMessage += names.get(i) + ",";
      }
      myHandler.send("<拒否リストの一覧>");
      myHandler.send(returnMessage);
    }

    // 引数有り reject
    else {
      String rejectName = strings[1];
      // 削除操作を行ったかどうかのフラグ
      boolean delete = false;
      // 登録操作を行ったかどうかのフラグ
      boolean regester = false;

      // 自分の拒否リストの中を順に見てゆき、
      // 引数指定の名前を持つハンドラが拒否リストにあれば(既に登録されていれば)、削除する。
      for (int i = 0; i < rejectList.size(); i++) {
        ChatClientHandler_345387 handler = (ChatClientHandler_345387) rejectList.get(i);

        // 既に拒否リストに登録されていたら
        if ((handler.name).equalsIgnoreCase(rejectName)) {
          // 拒否リストから削除
          rejectList.remove(handler);
          delete = true; // フラグを true に -> 今回、登録操作は行わない。
          // 報告
          myHandler.send(rejectName + "を拒否リストから削除しました。");
          System.out.println(myHandler.getClientName() + ": reject: " + rejectName + "を削除");
        }
      }

      // 削除を行わない場合、登録を行う。
      if (delete == false) {
        // まずは、引数で与えられた名前がクライアントリストに存在するかを一応チェック
        // -> 存在すれば、拒否リストに追加する。
        for (int i = 0; i < clients.size(); i++) {
          ChatClientHandler_345387 handler = (ChatClientHandler_345387) clients.get(i);

          // 引数で与えられた名前がクライアントに存在すれば、
          if ((handler.name).equalsIgnoreCase(rejectName)) {
            // 拒否リストへ登録する
            rejectList.add(handler);
            regester = true; // フラグをtrueに
            // 報告
            myHandler.send(rejectName + "を拒否リストへ登録しました。");
            System.out.println(myHandler.getClientName() + ": reject: " + rejectName + "を登録");
          }
        }

        // 登録できない(名前が存在しない)場合は、エラーメッセージを返送
        if (regester == false) myHandler.send("存在しない名前です");
      }

      // コマンドが成功した(登録、削除のどちらかが行われた)場合は現在の拒否リストの一覧を返す
      if (regester == true || delete == true) {
        // 拒否リストに居るユーザの名前一覧
        List names = new ArrayList();

        // 自分の現在の拒否リストから順番に名前を names リストに追加する。
        for (int i = 0; i < rejectList.size(); i++) {
          ChatClientHandler_345387 rejHandler = (ChatClientHandler_345387) rejectList.get(i);
          names.add(rejHandler.getClientName());
        }

        // names リストをソートして、自分に拒否リストの一覧を送る。
        String returnMessage = "";
        Collections.sort(names);
        for (int i = 0; i < names.size(); i++) {
          returnMessage += names.get(i) + ",";
        }
        myHandler.send("<拒否リストの一覧>");
        myHandler.send(returnMessage);
      }
    }

    return true;
  }
Beispiel #14
0
  private void mapAndTocForFile(File f, File path, String underscore) {
    // we get the single name of the file and the urlname
    int under_index2 = f.getName().indexOf("_");
    int point_index2 = f.getName().indexOf(".");
    String named = f.getName().substring(under_index2 + 1, point_index2);
    String tmp = path.getAbsolutePath() + "Main_pages/fr/";
    String url_name = f.getPath().replace("\\", "/").substring(tmp.length());
    String targetName = url_name.substring(0, url_name.lastIndexOf(".html"));

    // now we will add into the map and the toc
    print.println("<mapID target=\"" + targetName + "\" url=\"pages/" + url_name + "\"/>");
    File dir_associated = new File(f.getParent(), named);

    if ((dir_associated.exists() && dir_associated.isDirectory()) || named.equals("objects")) {
      print2.println(
          "<tocitem text=\"" + getTitle(f) + "\" target=\"" + targetName + "\" image=\"tamicon\">");
      if (dir_associated.exists()) {
        // Apres on fait pareil pour tous les sous fichiers
        File[] sub_files = dir_associated.listFiles();
        for (int i = 0; i < sub_files.length; i++) {
          if (!sub_files[i].getName().equals("CVS") && sub_files[i].isFile()) {
            if (sub_files[i].getName().endsWith(".html"))
              mapAndTocForFile(sub_files[i], path, underscore);
            else {
              try {
                copyFile(
                    sub_files[i], new File(path, "pages/" + named + "/" + sub_files[i].getName()));
              } catch (IOException e) {
                LOG.error("Error while copying normal files in help " + e);
              }
            }
          }
        }
      }
      if (named.equals("objects")) {
        // Specialement pour les objets on les rajoute tous
        File objects_dir =
            new File(
                Configuration.instance()
                        .getTangaraPath()
                        .getParentFile()
                        .getAbsolutePath()
                        .replace("\\", "/")
                    + "/objects/");
        File[] listfiles = objects_dir.listFiles();
        Vector<String> list_names = new Vector<String>();
        HashMap<String, String> map = new HashMap<String, String>();
        for (int i = 0; i < listfiles.length; i++) {
          try {
            if (listfiles[i].getName().endsWith(".jar")) {
              int point_index = listfiles[i].getName().lastIndexOf(".");
              String name = listfiles[i].getName().substring(0, point_index);

              // Copy the pages in the right directory
              File object_dir = new File(path, "pages/" + name);
              object_dir.mkdir();
              File object_ressource =
                  new File(
                      Configuration.instance()
                              .getTangaraPath()
                              .getParentFile()
                              .getAbsolutePath()
                              .replace("\\", "/")
                          + "/objects/resources/"
                          + name
                          + "/Help");
              if (object_ressource.exists()) {
                File[] list_html_object = object_ressource.listFiles();
                for (int e = 0; e < list_html_object.length; e++) {
                  if (list_html_object[e].getName().endsWith(".html")) {
                    int under_index = list_html_object[e].getName().lastIndexOf("_");
                    if (underscore.equals("") && under_index == -1)
                      copyFile(
                          list_html_object[e],
                          new File(path, "pages/" + name + "/" + list_html_object[e].getName()));
                    else if (!underscore.equals("")) {
                      if (list_html_object[e].getName().contains(underscore))
                        copyFile(
                            list_html_object[e],
                            new File(path, "pages/" + name + "/" + list_html_object[e].getName()));
                    }
                  } else
                    copyFile(
                        list_html_object[e],
                        new File(path, "pages/" + name + "/" + list_html_object[e].getName()));
                }
                // Gets the name of the object in the selected language
                String name_lang = null;
                if (underscore.equals("")) name_lang = name;
                else {
                  name_lang = getLangName(listfiles[i]);
                }
                if (name_lang != null) {
                  list_names.add(name_lang);
                  map.put(name_lang, name);
                  // Add to the map file
                  print.println(
                      "<mapID target=\""
                          + name
                          + "\" url=\"pages/"
                          + name
                          + "/index"
                          + underscore
                          + ".html\" />");
                }
              }
            }
          } catch (Exception e2) {
            LOG.error("Error2 getHelp " + e2);
          }
        }
        // Add to the tam file
        Collections.sort(list_names);
        for (String s : list_names) {
          print2.println(
              "<tocitem text=\"" + s + "\" target=\"" + map.get(s) + "\" image=\"fileicon\" />");
        }
      }
      print2.println("</tocitem>");
    } else {
      // pas de sous fichiers
      print2.println(
          "<tocitem text=\""
              + getTitle(f)
              + "\" target=\""
              + targetName
              + "\" image=\"fileicon\"/>");
    }

    File parent = new File(path, "pages/" + url_name.substring(0, url_name.lastIndexOf(named) - 3));
    if (!parent.exists()) parent.mkdirs();
    File in_pages = new File(path, "pages/" + url_name);
    try {
      in_pages.createNewFile();
      copyFile(f, in_pages);
    } catch (IOException e3) {
      LOG.error("Error 3 getHelp " + e3 + " " + f.getName());
    }
  }
Beispiel #15
0
  protected void processDir(TOTorrentFileHasher hasher, File dir, Vector encoded, String root)
      throws TOTorrentException {
    File[] dir_file_list = dir.listFiles();

    if (dir_file_list == null) {

      throw (new TOTorrentException(
          "TOTorrentCreate: directory '"
              + dir.getAbsolutePath()
              + "' returned error when listing files in it",
          TOTorrentException.RT_FILE_NOT_FOUND));
    }
    // sort contents so that multiple encodes of a dir always
    // generate same torrent

    List file_list = new ArrayList(Arrays.asList(dir_file_list));

    Collections.sort(file_list);

    long offset = 0;

    for (int i = 0; i < file_list.size(); i++) {

      File file = (File) file_list.get(i);

      String file_name = file.getName();

      if (!(file_name.equals(".") || file_name.equals(".."))) {

        if (file.isDirectory()) {

          if (root.length() > 0) {

            file_name = root + File.separator + file_name;
          }

          processDir(hasher, file, encoded, file_name);

        } else {

          if (!ignoreFile(file_name)) {

            if (root.length() > 0) {

              file_name = root + File.separator + file_name;
            }

            long length = hasher.add(file);

            TOTorrentFileImpl tf = new TOTorrentFileImpl(this, offset, length, file_name);

            offset += length;

            if (add_other_hashes) {

              byte[] ed2k_digest = hasher.getPerFileED2KDigest();
              byte[] sha1_digest = hasher.getPerFileSHA1Digest();

              // System.out.println( "file:ed2k = " + ByteFormatter.nicePrint( ed2k_digest, true ));
              // System.out.println( "file:sha1 = " + ByteFormatter.nicePrint( sha1_digest, true ));

              tf.setAdditionalProperty("sha1", sha1_digest);
              tf.setAdditionalProperty("ed2k", ed2k_digest);
            }

            encoded.addElement(tf);
          }
        }
      }
    }
  }