gt:       for (int h = 0; h < headers.size(); h++) {
context: /**
   * Copyright (C) 2000 - 2012 Silverpeas
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as
   * published by the Free Software Foundation, either version 3 of the
   * License, or (at your option) any later version.
   *
   * As a special exception to the terms and conditions of version 3.0 of
   * the GPL, you may redistribute this Program in connection with Free/Libre
   * Open Source Software ("FLOSS") applications as described in Silverpeas's
   * FLOSS exception.  You should have received a copy of the text describing
   * the FLOSS exception, and it is also available here:
   * "http://www.silverpeas.org/docs/core/legal/floss_exception.html"
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program.  If not, see <http://www.gnu.org/licenses/>.
   */
  
  package com.silverpeas.coordinates.importExport;
  
  import java.rmi.RemoteException;
  import java.util.ArrayList;
  import java.util.Collection;
  import java.util.List;
  import java.util.StringTokenizer;
  
  import com.stratelia.webactiv.util.DateUtil;
  import com.stratelia.webactiv.util.EJBUtilitaire;
  import com.stratelia.webactiv.util.JNDINames;
  import com.stratelia.webactiv.util.ResourceLocator;
  import com.stratelia.webactiv.util.coordinates.control.CoordinatesBm;
  import com.stratelia.webactiv.util.coordinates.control.CoordinatesBmHome;
  import com.stratelia.webactiv.util.coordinates.model.CoordinatePK;
  import com.stratelia.webactiv.util.coordinates.model.CoordinatePoint;
  import com.stratelia.webactiv.util.coordinates.model.CoordinateRuntimeException;
  import com.stratelia.webactiv.util.exception.SilverpeasRuntimeException;
  import com.stratelia.webactiv.util.node.control.NodeBm;
  import com.stratelia.webactiv.util.node.control.NodeBmHome;
  import com.stratelia.webactiv.util.node.model.NodeDetail;
  import com.stratelia.webactiv.util.node.model.NodePK;
  import com.stratelia.webactiv.util.node.model.NodeRuntimeException;
  import com.stratelia.silverpeas.silvertrace.SilverTrace;
  
  /**
   * Classe gerant la manipulation des axes de coordinates pour le module d'importExport.
   * @author dlesimple
   */
  public class CoordinateImportExport {
  
    /**
     * @param componentId
     * @param axisPath (/0/1024/1043,/0/1036,/0/1040)
     * @return coordinateId
     * @throws CoordinateRuntimeException
     */
    public int addPositions(String componentId, String axisPath)
        throws CoordinateRuntimeException {
      List<String> combination = getArrayCombination(axisPath);
      SilverTrace.debug("coordinates", "CoordinateImportExport.addPositions",
          "root.MSG_GEN_PARAM_VALUE", "combination = " + combination);
      int coordinateId = 0;
      NodePK axisPK = new NodePK("toDefine", componentId);
      CoordinatePK coordinatePK = new CoordinatePK("unknown", axisPK);
      try {
        NodeBm nodeBm = getNodeBm();
        // enrich combination by get ancestors
        List<CoordinatePoint> allnodes = new ArrayList<CoordinatePoint>();
        int i = 1;
        for (String nodeId : combination) {
          SilverTrace.info("coordinates", "CoordinateImportExport.addPositions()",
              "root.MSG_GEN_PARAM_VALUE", "nodeId = " + nodeId);
          NodePK nodePK = new NodePK(nodeId, componentId);
          SilverTrace.info("coordinates", "CoordinateImportExport.addPositions()",
              "root.MSG_GEN_PARAM_VALUE", "avant nodeBm.getPath() ! i = " + i);
          Collection<NodeDetail> path = nodeBm.getPath(nodePK);
          SilverTrace.info("coordinates", "CoordinateImportExport.addPositions()",
              "root.MSG_GEN_PARAM_VALUE", "path for nodeId " + nodeId + " = " + path.toString());
          for (NodeDetail nodeDetail : path) {
            String anscestorId = nodeDetail.getNodePK().getId();
            int nodeLevel = nodeDetail.getLevel();
            if (!nodeDetail.getNodePK().isRoot()) {
              CoordinatePoint point;
              if (anscestorId.equals(nodeId)) {
                point = new CoordinatePoint(-1, Integer.parseInt(anscestorId), true, nodeLevel, i);
              } else {
                point = new CoordinatePoint(-1, Integer.parseInt(anscestorId), false, nodeLevel, i);
              }
              allnodes.add(point);
            }
          }
          i++;
        }
        coordinateId = getCoordinatesBm().addCoordinate(coordinatePK, allnodes);
      } catch (Exception e) {
        throw new CoordinateRuntimeException("CoordinateImportExport.addPositions()",
            SilverpeasRuntimeException.ERROR, "coordinates.ADDING_COORDINATES_COMBINATION_FAILED", e);
      }
      SilverTrace.debug("coordinates", "CoordinateImportExport.addPositions()",
          "root.MSG_GEN_PARAM_VALUE", "coordinateId = " + coordinateId);
      return coordinateId;
    }
  
    /**
     * Get a node by its name.
     * @param name
     * @param nodeRootId
     * @param componentId
     * @return
     */
    public NodeDetail getNodeDetailByName(String name, int nodeRootId, String componentId) {
      SilverTrace.debug("coordinates", "CoordinateImportExport.getNodeDetailByName()",
          "root.MSG_GEN_PARAM_VALUE", "name = " + name + " nodeRootId=" + nodeRootId
          + " componentId=" + componentId);
      try {
        NodeDetail nodeDetail = getNodeBm().getDetailByNameAndFatherId(new NodePK("useless",
            componentId), name, nodeRootId);
        return nodeDetail;
      } catch (Exception e) {
        throw new CoordinateRuntimeException("CoordinateImportExport.addNodesToPublication()",
            SilverpeasRuntimeException.ERROR, "coordinates.ATTACHING_NODES_TO_PUBLICATION_FAILED", e);
      }
    }
  
    /**
     * Get ArrayList of valuePath (/xx/yyy, /xx/yyy/zzzz/ to arrayList with /xx/yy then /xx/yyy/zzzz)
     * @param valuePath
     * @return ArrayList
     */
    private List<String> getArrayCombination(String valuePath) {
      StringTokenizer st = new StringTokenizer(valuePath, ",");
      List<String> combination = new ArrayList<String>();
      while (st.hasMoreTokens()) {
        String axisValue = st.nextToken();
        axisValue = axisValue.substring(axisValue.lastIndexOf('/') + 1, axisValue.length());
        combination.add(axisValue);
      }
      return combination;
    }
  
    /**
     * Get ArrayList of valuePath labels (/xx/yyy, /xx/yyy/zzzz/ to arrayList with Axe1 > value15 then
     * Axe2 > value5)
     * @param combination
     * @param componentId
     * @return a List of displayName: Axe1 > value15
     * @throws RemoteException
     */
    public List<String> getCombinationLabels(List<String> combination, String componentId)
        throws RemoteException {
      List<String> coordinatesLabels = new ArrayList<String>();
      for (String position : combination) {
        StringTokenizer st = new StringTokenizer(position, "/");
        StringBuilder pathName = new StringBuilder();
        while (st.hasMoreTokens()) {
          String nodeId = st.nextToken();
          NodeDetail nodeDetail = getNodeHeader(nodeId, componentId);
          // Don't take the root
          if (nodeDetail.getLevel() > 1) {
            if (nodeDetail.getLevel() == 2) {
              pathName.append("<b>").append(nodeDetail.getName()).append("</b>").append(" > ");
            } else if (!st.hasMoreTokens()) {
              pathName.append(nodeDetail.getName()).append("<br />");
            } else {
              pathName.append(nodeDetail.getName()).append(" > ");
            }
          }
        }
        coordinatesLabels.add(pathName.toString());
      }
      return coordinatesLabels;
    }
  
    public Collection<NodeDetail> getPathOfNode(NodePK nodePk) {
      Collection<NodeDetail> listNodeDetail = null;
      try {
        listNodeDetail = getNodeBm().getPath(nodePk);
      } catch (RemoteException ex) {
        throw new NodeRuntimeException("NodeImportExport.getPathOfNode()",
            SilverpeasRuntimeException.ERROR, "node.GETTING_NODE_PATH_FAILED", ex);
      }
      return listNodeDetail;
    }
  
    /**
     * Get axis of the component
     * @param componentId
     * @return
     */
    public List<NodeDetail> getAxis(String componentId) {
      ResourceLocator nodeSettings = new ResourceLocator(
          "com.stratelia.webactiv.util.node.nodeSettings", "");
      String sortField = nodeSettings.getString("sortField", "nodepath");
      String sortOrder = nodeSettings.getString("sortOrder", "asc");
      List<NodeDetail> axis = new ArrayList<NodeDetail>();
      try {
        List headers = getAxisHeaders(componentId);
        NodeDetail header = null;
  