/*
   * @see com.stratelia.silverpeas.silverpeasinitialize.CallBack#doInvoke(int, int,
   * java.lang.String, java.lang.Object)
   */
  @Override
  public void doInvoke(int action, int iParam, String sParam, Object extraParam) {
    SilverTrace.info(
        "Pdc",
        "PdcCallBack.doInvoke()",
        "root.MSG_GEN_ENTER_METHOD",
        "action = " + action + ", iParam = " + iParam);

    if (iParam == -1) {
      SilverTrace.info(
          "Pdc",
          "PdcCallBack.doInvoke()",
          "root.MSG_GEN_PARAM_VALUE",
          "userId or groupId is null. Callback stopped ! action = "
              + action
              + ", sParam = "
              + sParam
              + ", extraParam = "
              + extraParam.toString());
      return;
    }

    try {
      PdcBm pdcBm = new PdcBmImpl();

      if (action == CallBackManager.ACTION_BEFORE_REMOVE_USER) {
        pdcBm.deleteManager(String.valueOf(iParam));
      } else if (action == CallBackManager.ACTION_BEFORE_REMOVE_GROUP) {
        pdcBm.deleteGroupManager(String.valueOf(iParam));
      }

    } catch (Exception e) {
      throw new PdcRuntimeException(
          "PdcCallBack.doInvoke()",
          SilverpeasRuntimeException.ERROR,
          "root.EX_CANT_GET_REMOTE_OBJECT",
          e);
    }
  }
Example #2
0
  @Override
  public int doStartTag() throws JspException {
    if (pdcBm == null) {
      pdcBm = (PdcBm) new PdcBmImpl();
    }

    List<SearchAxis> primaryAxis = null;
    List daughters = null;

    try {
      if (StringUtil.isDefined(m_spaceOrSubSpace)) {
        List<String> availableComponentIds = new ArrayList<String>();
        SearchContext searchContext = new SearchContext();

        if (StringUtil.isDefined(componentId)) {
          primaryAxis = pdcBm.getPertinentAxisByInstanceId(searchContext, "P", componentId);
        } else {
          String a[] =
              oganisationController.getAvailCompoIds(
                  m_spaceOrSubSpace, mainSessionController.getUserId());
          availableComponentIds = Arrays.asList(a);
          if (!availableComponentIds.isEmpty()) {
            primaryAxis =
                pdcBm.getPertinentAxisByInstanceIds(searchContext, "P", availableComponentIds);
          }
        }

        if (primaryAxis != null && !primaryAxis.isEmpty()) {
          if (!"".equals(selectedAxisId)) {
            if (StringUtil.isDefined(componentId)) {
              daughters =
                  pdcBm.getPertinentDaughterValuesByInstanceId(
                      searchContext, selectedAxisId, selectedAxisPath, componentId);
            } else {
              daughters =
                  pdcBm.getPertinentDaughterValuesByInstanceIds(
                      searchContext, selectedAxisId, selectedAxisPath, availableComponentIds);
            }
          } else {
            SearchAxis searchAxis = primaryAxis.get(0);
            String axisId = new Integer(searchAxis.getAxisId()).toString();
            daughters =
                pdcBm.getPertinentDaughterValuesByInstanceIds(
                    searchContext, axisId, "", availableComponentIds);
          }
        }
      } // end if
    } catch (PdcException e) {
      throw new JspTagException("PdcException occured : " + e.toString());
    }

    try {
      pageContext.getOut().println("<tr class='intfdcolor51'>");
      pageContext.getOut().println("	<td width='100%'>");
      pageContext
          .getOut()
          .println("		<table border='0' cellspacing='0' cellpadding='0' width='100%'>");
      pageContext.getOut().println("			<tr>");
      pageContext.getOut().println("				<td>&nbsp;</td>");
      pageContext.getOut().println("				<td width='100%'><span class='txtnote'>");
      pageContext
          .getOut()
          .println("					<table cellpadding=0 cellspacing=0 border=0 width='100%'>");
      pageContext.getOut().println("						<tr><td>");

      // il peut y avoir aucun axe primaire dans un 1er temps
      if ((primaryAxis != null) && !primaryAxis.isEmpty()) {
        String text_link = "";
        for (SearchAxis searchAxis : primaryAxis) {
          String axisId = new Integer(searchAxis.getAxisId()).toString();
          String axisRootId = new Integer(searchAxis.getAxisRootId()).toString();
          String axisName = EncodeHelper.javaStringToHtmlString(searchAxis.getAxisName());

          int nbPositions = searchAxis.getNbObjects();
          if (nbPositions == 0 && componentId != null) {
            continue;
          }
          String objectLinked = "";
          String link = "javascript:top.scriptFrame.axisClick('" + axisId + "','');";
          text_link =
              webContext
                  + "/RpdcSearch/jsp/showaxishfromhomepage?query=&AxisId="
                  + axisId
                  + "&ValueId=/"
                  + axisRootId
                  + "/&SearchContext=isNotEmpty&component_id="
                  + componentId
                  + "&space_id="
                  + m_spaceOrSubSpace;
          if (axisId.equals(selectedAxisId)) {
            if (daughters != null) {
              if ("".equals(selectedAxisPath)) {
                if ("off".equals(state)) {
                  pageContext
                      .getOut()
                      .println(
                          HomePageFunctions.urlFactory(
                              link,
                              text_link,
                              axisId,
                              "",
                              objectLinked,
                              axisName,
                              "&nbsp;(" + nbPositions + ")",
                              HomePageFunctions.AXIS,
                              HomePageFunctions.AXIS_COLLAPSED,
                              "",
                              webContext));
                  continue;
                }
              }
              pageContext
                  .getOut()
                  .println(
                      HomePageFunctions.urlFactory(
                          link,
                          text_link,
                          axisId,
                          "",
                          objectLinked,
                          axisName,
                          "&nbsp;(" + nbPositions + ")",
                          HomePageFunctions.AXIS,
                          HomePageFunctions.AXIS_EXPANDED,
                          "",
                          webContext));
              // **************Begin daughters

              int d_size = daughters.size();

              int[][] tree_gui_represintation = new int[d_size][d_size];
              int selected_x = -1;
              int selected_y = 0;

              for (int j = 0; j < d_size; j++) {
                Value value = (Value) daughters.get(j);
                int valueLevel = value.getLevelNumber();
                String path = value.getFullPath();
                HomePageFunctions.setTreeNode(tree_gui_represintation, valueLevel, j, d_size);
                if (selectedAxisPath.equals(path)) {
                  selected_x = valueLevel;
                  selected_y = j;
                }
              }

              HomePageFunctions.closeTreeNodes(tree_gui_represintation, 0, d_size, d_size);
              if (selected_x >= 0) {
                if (state.equals("on")) {
                  selected_x++;
                  selected_y++;
                }
                HomePageFunctions.collapseTree(
                    tree_gui_represintation, selected_x, selected_y, d_size);
              }

              for (int j = 1; j < d_size; j++) {
                Value value = (Value) daughters.get(j);
                String valueName = EncodeHelper.javaStringToHtmlString(value.getName());
                int valueLevel = value.getLevelNumber();
                int valueNbObjects = value.getNbObjects();
                if (valueNbObjects == 0 && componentId != null) {
                  continue;
                }
                String valueFullPath = value.getFullPath();
                link =
                    "javascript:top.scriptFrame.axisClick('"
                        + axisId
                        + "','"
                        + valueFullPath
                        + "');";
                text_link =
                    webContext
                        + "/RpdcSearch/jsp/showaxishfromhomepage?query=&AxisId="
                        + axisId
                        + "&ValueId="
                        + valueFullPath
                        + "&SearchContext=isNotEmpty&component_id="
                        + componentId
                        + "&space_id="
                        + m_spaceOrSubSpace;
                if (tree_gui_represintation[0][j] == HomePageFunctions.T_HIDED_NODE) {
                  continue;
                }
                String offset =
                    HomePageFunctions.getTreeNodeOffset(
                        tree_gui_represintation, j, d_size, webContext);
                int node_type;
                if (tree_gui_represintation[valueLevel][j] == HomePageFunctions.T_OPENED_NODE) {
                  node_type = HomePageFunctions.AXIS_EXPANDED;
                } else {
                  node_type = HomePageFunctions.AXIS_COLLAPSED;
                }
                if (selectedAxisPath.equals("")) {
                  if (valueLevel == 1) {
                    pageContext
                        .getOut()
                        .println(
                            HomePageFunctions.urlFactory(
                                link,
                                text_link,
                                valueFullPath,
                                "",
                                objectLinked,
                                valueName,
                                " (" + valueNbObjects + ")",
                                HomePageFunctions.AXIS_LAST,
                                HomePageFunctions.AXIS_COLLAPSED,
                                offset,
                                webContext));
                  }
                  continue;
                } else {
                  pageContext
                      .getOut()
                      .println(
                          HomePageFunctions.urlFactory(
                              link,
                              text_link,
                              valueFullPath,
                              "",
                              objectLinked,
                              valueName,
                              " (" + valueNbObjects + ")",
                              HomePageFunctions.AXIS_LAST,
                              node_type,
                              offset,
                              webContext));
                }
              }
            }
          } else {
            pageContext
                .getOut()
                .println(
                    HomePageFunctions.urlFactory(
                        link,
                        text_link,
                        axisId,
                        "",
                        objectLinked,
                        axisName,
                        "&nbsp;(" + nbPositions + ")",
                        HomePageFunctions.AXIS,
                        HomePageFunctions.AXIS_COLLAPSED,
                        "",
                        webContext));
          }
        } // fin du for
      }

      pageContext.getOut().println("						</td></tr>");
      pageContext.getOut().println("					</table>");
      pageContext.getOut().println("				</span></td>");
      pageContext.getOut().println("			</tr>");
      pageContext.getOut().println("		</table>");
      pageContext.getOut().println("	</td>");
      pageContext.getOut().println("	<td><img src='icons/1px.gif'></td>");
      pageContext.getOut().println("	<td class='intfdcolor'><img src='icons/1px.gif'></td>");
      pageContext.getOut().println("</tr>");
    } catch (IOException ioe) {
      throw new JspTagException("IO_ERROR");
    }

    return SKIP_BODY;
  }