public void updateQtree(
      String qtree, String volume, String mode, Boolean opLocks, String securityStyle) {
    NaElement elem = new NaElement("qtree-modify");
    elem.addNewChild("qtree", qtree);
    elem.addNewChild("volume", volume);

    // Set the oplocks for qtree
    if (opLocks.booleanValue() == true) {
      elem.addNewChild("oplocks", ENABLE);
    } else {
      elem.addNewChild("oplocks", DISABLE);
    }

    /* Set the security style; if input is default we do not set it.
     * In that case, the qtree inherits the parent volume's security
     * style.
     */
    if (securityStyle.equalsIgnoreCase(UNIX)) {
      elem.addNewChild("security-style", UNIX);
    } else if (securityStyle.equalsIgnoreCase(NTFS)) {
      elem.addNewChild("security-style", NTFS);
    } else if (securityStyle.equalsIgnoreCase(MIXED)) {
      elem.addNewChild("security-style", MIXED);
    }

    if (StringUtils.isNotBlank(mode)) {
      elem.addNewChild("mode", mode);
    }

    try {
      server.invokeElem(elem);
    } catch (Exception e) {
      throw createError(elem, e);
    }
  }
  public void deleteQtree(String qtree, boolean force) {
    NaElement elem = new NaElement("qtree-delete");
    elem.addNewChild("qtree", qtree);
    elem.addNewChild("force", String.valueOf(force));

    try {
      server.invokeElem(elem);
    } catch (Exception e) {
      throw createError(elem, e);
    }
  }
  public boolean isQtree(String volume, String qtreeName) {
    NaElement elem = new NaElement("qtree-list-iter");

    if ((volume != null && !volume.isEmpty()) && (qtreeName != null && !qtreeName.isEmpty())) {
      NaElement qtreeAttrs = new NaElement("qtree-info");
      qtreeAttrs.addNewChild("volume", volume);
      qtreeAttrs.addNewChild("qtree", qtreeName);
      NaElement query = new NaElement("query");
      query.addChildElem(qtreeAttrs);
      elem.addChildElem(query);
    }

    try {
      NaElement results = server.invokeElem(elem);
      if (results.getChildIntValue("num-records", 0) > 0) {
        return true;
      }
    } catch (Exception e) {
      throw createError(elem, e);
    }
    return false;
  }
  public List<Qtree> listQtree(String volume) {
    NaElement elem = new NaElement("qtree-list-iter");

    if (volume != null && !volume.isEmpty()) {
      NaElement qtreeAttrs = new NaElement("qtree-info");
      qtreeAttrs.addNewChild("volume", volume);
      NaElement query = new NaElement("query");
      query.addChildElem(qtreeAttrs);
      elem.addChildElem(query);
    }

    NaElement resultElem = null;
    String tag = null;
    List<Qtree> qtrees = Lists.newArrayList();
    try {
      do {
        NaElement results = server.invokeElem(elem);
        tag = results.getChildContent("next-tag");
        resultElem = results.getChildByName("attributes-list");
        if (resultElem != null) {
          // Get the number of records returned by API.
          for (NaElement qtreeElem : (List<NaElement>) resultElem.getChildren()) {
            if (qtreeElem != null) {
              Qtree qtree = new Qtree();
              qtree.setId(
                  (Integer) ConvertUtils.convert(qtreeElem.getChildContent("id"), Integer.class));
              qtree.setOplocks(qtreeElem.getChildContent("oplocks"));
              qtree.setOwningVfiler(qtreeElem.getChildContent("vserver"));
              qtree.setQtree(qtreeElem.getChildContent("qtree"));
              qtree.setSecurityStyle(qtreeElem.getChildContent("security-style"));
              qtree.setStatus(qtreeElem.getChildContent("status"));
              qtree.setVolume(qtreeElem.getChildContent("volume"));
              qtrees.add(qtree);
            }
          }
        }
        if (tag != null && !tag.isEmpty()) {
          elem = new NaElement("qtree-list-iter");
          elem.addNewChild("tag", tag);
        }
      } while (tag != null && !tag.isEmpty());
    } catch (Exception e) {
      throw createError(elem, e);
    }
    return qtrees;
  }
 protected NetAppCException createError(NaElement elem, Exception e) {
   String message = "Failed to run " + elem.getName();
   log.error(message, e);
   return new NetAppCException(message, e);
 }