コード例 #1
0
  /** Returns child <code>TreeNode</code>s for the given <code>TreeNode</code> model Object. */
  public List getChildTreeNodeObjects(Object nodeObject) {
    if (nodeObject == null) {
      return null;
    }
    // if (nodeObject.toString().equals(_objectName)) {
    // In this implementation _objectName represents the top-level,
    // we need to find its children here
    // if (_children != null) {
    //    return Arrays.asList((Object[])_children);
    // }

    String context = "";
    if (nodeObject instanceof NameClassPair) {

      context = (String) ((NameClassPair) nodeObject).getName();
      _nodeClass = (String) ((NameClassPair) nodeObject).getClassName();
    }

    List transformed = new ArrayList();
    try {
      ArrayList result =
          (ArrayList)
              JMXUtil.getMBeanServer()
                  .invoke(
                      new ObjectName(_objectName),
                      "getNames",
                      new String[] {context},
                      new String[] {"java.lang.String"});
      for (int i = 0; i < result.size(); i++) {
        NameClassPair pair = (NameClassPair) result.get(i);
        String nm = pair.getName();
        String prepend = context.equals("") ? "" : context + "/";
        pair.setName(prepend + pair.getName());
        transformed.add(pair);
      }
      _children = transformed.toArray(new Object[0]);

      // Ok, we got the result, provide an event in case we want to
      // do some filtering
      FacesContext ctx = FacesContext.getCurrentInstance();
      Object retVal =
          getLayoutComponent()
              .dispatchHandlers(
                  ctx,
                  FilterTreeEvent.EVENT_TYPE,
                  new FilterTreeEvent(getParentUIComponent(), _children));
      if ((retVal != null) && (retVal instanceof Object[])) {
        // We have a return value, use it instead of the original list
        _children = (Object[]) retVal;
      }
    } catch (Exception ex) {
      // Ignore exception since there are no children
      _children = null;
    }

    return _children != null ? Arrays.asList((Object[]) _children) : null;
  }
コード例 #2
0
ファイル: DXOps.java プロジェクト: idega/com.idega.block.ldap
  /**
   * This postparses a namingEnumeration of NameClassPairs, after it has been returned from the jndi
   * operation. Usefull to over-ride if the names in the enumeration need to be unescaped or
   * reformatted.
   *
   * @param e the post jndi operation namingEnumeration.
   * @param base the 'base' dn from which the names in the enumeration (may) be relative. If the
   *     Names in the enumeration are suffixed by the searchBase, they are unaltered, otherwise the
   *     searchBase is added to the names to give the full DN in the namespace.
   * @return the re-formatted version used by the application.
   */
  public NamingEnumeration postParseNameClassPairs(NamingEnumeration e, Name base)
      throws NamingException {
    log.log(Level.FINER, "parsing with base :" + base.toString());
    DXNamingEnumeration dxe = new DXNamingEnumeration();

    String baseString = null;

    if (base != null && base.isEmpty() == false) baseString = base.toString();

    try {
      while (e.hasMore()) {
        NameClassPair ncp = (NameClassPair) e.next();

        String rawName = postParseString(ncp.getName()).toString();

        // IMPORTANT!
        // This appends the 'base' DN to the enumerated DNs in order to get absolute DNs...

        if (ncp.isRelative() && baseString != null) {
          if (rawName.length() != 0) rawName = rawName + "," + baseString;
          else rawName = baseString;
        }

        log.log(Level.FINER, "ended up with: '" + rawName + "'");
        ncp.setName(rawName);
        dxe.add(ncp);
      }
    } catch (NamingException ex) {
      CBUtility.error(
          CBIntText.get("Search partially failed! - only ")
              + dxe.size()
              + CBIntText.get(" entries returned."),
          ex);
    }

    return dxe;
  }