public void _jspService(HttpServletRequest request, HttpServletResponse response)
      throws java.io.IOException, ServletException {

    JspFactory _jspxFactory = null;
    javax.servlet.jsp.PageContext pageContext = null;
    HttpSession session = null;
    ServletContext application = null;
    ServletConfig config = null;
    JspWriter out = null;
    Object page = this;
    JspWriter _jspx_out = null;

    try {
      _jspxFactory = JspFactory.getDefaultFactory();
      response.setContentType("text/html;charset=ISO-8859-1");
      pageContext = _jspxFactory.getPageContext(this, request, response, null, true, 8192, true);
      application = pageContext.getServletContext();
      config = pageContext.getServletConfig();
      session = pageContext.getSession();
      out = pageContext.getOut();
      _jspx_out = out;

      out.write("\n\n");
      out.write("\n\n");

      // Get required parameter(s)
      String nodeIdStr = request.getParameter("node");
      if (nodeIdStr == null) throw new org.opennms.web.MissingParameterException("node");
      int nodeId = Integer.parseInt(nodeIdStr);
      String nodeLabel = org.opennms.web.element.NetworkElementFactory.getNodeLabel(nodeId);
      Node node_db = NetworkElementFactory.getNode(nodeId);
      String orgName = node_db.getOrganizationName();
      Asset asset = this.model.getAsset(nodeId);
      boolean isNew = false;

      if (asset == null) {
        asset = new Asset();
        isNew = true;
      }

      Vector vCategories = WTProperties.getList("AssetCategories.list");

      out.write("\n\n");
      out.write("<html>\n");
      out.write("<head>\n\t");
      out.write("<title>WebTelemetry - Node Assets | System Info for ");
      out.print(node_db.getLabel());
      out.write("</title>\n\t");
      out.write("<base HREF=\"");
      out.print(org.opennms.web.Util.calculateUrlBase(request));
      out.write("\" />\n\t");
      out.write(
          "<link rel=\"stylesheet\" type=\"text/css\" href=\"/wt-portal/css/default.css\" />\n\t");
      out.write("<script type=\"text/javascript\" src=\"/wt-portal/javascript/WTtools.js\">");
      out.write("</script>\n");
      out.write("</head>\n\n");
      out.write("<body>\n\t");
      out.write("<!-- Header -->\n\t");
      String title = "Asset - Vendor Info for Node: " + node_db.getLabel() + " (" + orgName + ")";
      out.write("\n\t");
      JspRuntimeLibrary.include(
          request,
          response,
          "/includes/tabheader.jsp"
              + "?"
              + "title="
              + java.net.URLEncoder.encode("" + title)
              + "&"
              + "refresh="
              + "1"
              + "&"
              + "helpURL="
              + "assetmanager%2FWTHelp_AssetManager.html"
              + "&"
              + "tabgroup="
              + "asset"
              + "&"
              + "tabselected="
              + "vendor"
              + "&"
              + "node="
              + java.net.URLEncoder.encode("" + nodeIdStr),
          out,
          false);
      out.write("\n\n");
      out.write("<!-- BEGIN FRAMING TABLE:open tags, keep at 100%-->\n");
      out.write("<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n\t");
      out.write("<tr>\n\t\t");
      out.write("<td width=\"10\">");
      out.write(
          "<img src=\"/wt-portal/images/spacers/spacer.gif\" height=\"1\" width=\"10\" border=\"0\" alt=\"WebTelemetry\">");
      out.write("</td>\n\t\t");
      out.write("<td>\n\n");
      out.write("<!-- USER-DEFINED ATTRIBUTES TABLE: was Identification -->\n      ");
      out.write("<form action=\"asset/modifyAsset\" method=\"POST\" name=\"sysInfo\">\n        ");
      out.write("<input type=\"hidden\" name=\"node\" value=\"");
      out.print(nodeId);
      out.write("\" />\n        ");
      out.write("<input type=\"hidden\" name=\"isnew\" value=\"");
      out.print(isNew);
      out.write("\" />\n        ");
      out.write("<input type=\"hidden\" name=\"view\" value=\"asset-tab-vendor\" />\n\n        ");
      if (!isNew) {
        out.write("\n        ");
        out.write("<!-- asset-tab-system -->\n        ");
        out.write("<input type=\"hidden\" name=\"category\" value=\"");
        out.print(asset.getCategory());
        out.write("\" />\n        ");
        out.write("<input type=\"hidden\" name=\"serialnumber\" value=\"");
        out.print(asset.getSerialNumber());
        out.write("\" />\n        ");
        out.write("<input type=\"hidden\" name=\"manufacturer\" value=\"");
        out.print(asset.getManufacturer());
        out.write("\" />\n        ");
        out.write("<input type=\"hidden\" name=\"operatingsystem\" value=\"");
        out.print(asset.getOperatingSystem());
        out.write("\" />\n        ");
        out.write("<input type=\"hidden\" name=\"modelnumber\" value=\"");
        out.print(asset.getModelNumber());
        out.write("\" />\n        ");
        out.write("<input type=\"hidden\" name=\"assetnumber\" value=\"");
        out.print(asset.getAssetNumber());
        out.write("\" />\n        ");
        out.write("<input type=\"hidden\" name=\"dateinstalled\" value=\"");
        out.print(asset.getDateInstalled());
        out.write("\" />\n        ");
        out.write("<input type=\"hidden\" name=\"description\" value=\"");
        out.print(asset.getDescription());
        out.write("\" />\n        ");
        out.write("<input type=\"hidden\" name=\"comments\" value=\"");
        out.print(asset.getComments());
        out.write("\" />\n\n        ");
        out.write("<!-- asset-tab-location -->\n        ");
        out.write("<input type=\"hidden\" name=\"region\" value=\"");
        out.print(asset.getRegion());
        out.write("\" />\n        ");
        out.write("<input type=\"hidden\" name=\"division\" value=\"");
        out.print(asset.getDivision());
        out.write("\" />\n        ");
        out.write("<input type=\"hidden\" name=\"department\" value=\"");
        out.print(asset.getDepartment());
        out.write("\" />\n        ");
        out.write("<input type=\"hidden\" name=\"address1\" value=\"");
        out.print(asset.getAddress1());
        out.write("\" />\n        ");
        out.write("<input type=\"hidden\" name=\"address2\" value=\"");
        out.print(asset.getAddress2());
        out.write("\" />\n        ");
        out.write("<input type=\"hidden\" name=\"city\" value=\"");
        out.print(asset.getCity());
        out.write("\" />\n        ");
        out.write("<input type=\"hidden\" name=\"state\" value=\"");
        out.print(asset.getState());
        out.write("\" />\n        ");
        out.write("<input type=\"hidden\" name=\"zip\" value=\"");
        out.print(asset.getZip());
        out.write("\" />\n        ");
        out.write("<input type=\"hidden\" name=\"building\" value=\"");
        out.print(asset.getBuilding());
        out.write("\" />\n        ");
        out.write("<input type=\"hidden\" name=\"floor\" value=\"");
        out.print(asset.getFloor());
        out.write("\" />\n        ");
        out.write("<input type=\"hidden\" name=\"room\" value=\"");
        out.print(asset.getRoom());
        out.write("\" />\n        ");
        out.write("<input type=\"hidden\" name=\"rack\" value=\"");
        out.print(asset.getRack());
        out.write("\" />\n        ");
        out.write("<input type=\"hidden\" name=\"slot\" value=\"");
        out.print(asset.getSlot());
        out.write("\" />\n        ");
        out.write("<input type=\"hidden\" name=\"port\" value=\"");
        out.print(asset.getPort());
        out.write("\" />\n        ");
        out.write("<input type=\"hidden\" name=\"circuitid\" value=\"");
        out.print(asset.getCircuitId());
        out.write("\" />\n        ");
      }
      out.write("\n\n");
      out.write("<!-- END FRAMING TABLE:open tags, keep at 100%-->\n\t");
      out.write("<table width=\"98%\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\">\n\t  ");
      out.write("<tr class=\"tableHeader\">\n\t    ");
      out.write("<td colspan=\"6\" class=\"tableHeader\">Vendor");
      out.write("</td>\n\t  ");
      out.write("</tr>\n\t  ");
      out.write("<tr class=\"tableRowLight\">\n\t    ");
      out.write("<td class=\"tableText\">");
      out.write("<span class=\"formText\">Name:");
      out.write("</span>");
      out.write("</td>\n\t    ");
      out.write("<td class=\"tableText\">");
      out.write("<input type=\"text\" name=\"vendor\" value=\"");
      out.print(asset.getVendor());
      out.write("\" size=\"20\" maxlength=\"64\"/>");
      out.write("</td>\n\t    ");
      out.write("<td class=\"tableText\">");
      out.write("<span class=\"formText\">Phone:");
      out.write("</span>");
      out.write("</td>\n\t    ");
      out.write("<td class=\"tableText\">");
      out.write("<input type=\"text\" name=\"vendorphone\" value=\"");
      out.print(asset.getVendorPhone());
      out.write("\" size=\"20\" maxlength=\"64\"/>");
      out.write("</td>\n\t    ");
      out.write("<td class=\"tableText\">");
      out.write("<span class=\"formText\">Fax:");
      out.write("</span>");
      out.write("</td>\n\t    ");
      out.write("<td class=\"tableText\">");
      out.write("<input type=\"text\" name=\"vendorfax\"  value=\"");
      out.print(asset.getVendorFax());
      out.write("\" size=\"20\" maxlength=\"64\"/>");
      out.write("</td>\n\t  ");
      out.write("</tr>\n\t  ");
      out.write("<tr class=\"tableRowLight\">\n\t    ");
      out.write("<td class=\"tableText\">");
      out.write("<span class=\"formText\">Lease:");
      out.write("</span>");
      out.write("</td>\n\t    ");
      out.write("<td class=\"tableText\">");
      out.write("<input type=\"text\" name=\"lease\" value=\"");
      out.print(asset.getLease());
      out.write("\" size=\"20\" maxlength=\"64\"/>");
      out.write("</td>\n\t    ");
      out.write("<td class=\"tableText\">");
      out.write("<span class=\"formText\">Lease Expires:");
      out.write("</span>");
      out.write("</td>\n\t    ");
      out.write("<td class=\"tableText\">");
      out.write("<input type=\"text\" name=\"leaseexpires\" value=\"");
      out.print(asset.getLeaseExpires());
      out.write("\" size=\"20\" maxlength=\"64\"/>");
      out.write("</td>\n\t    ");
      out.write("<td class=\"tableText\">");
      out.write("<span class=\"formText\">Vendor Asset:");
      out.write("</span>");
      out.write("</td>\n\t    ");
      out.write("<td class=\"tableText\">");
      out.write("<input type=\"text\" name=\"vendorassetnumber\" value=\"");
      out.print(asset.getVendorAssetNumber());
      out.write("\" size=\"20\" maxlength=\"64\"/>");
      out.write("</td>\n\t  ");
      out.write("</tr>\n\t  ");
      out.write("<tr class=\"tableRowLight\">\n\t    ");
      out.write("<td class=\"tableText\">");
      out.write("<span class=\"formText\">Maint Contract:");
      out.write("</span>");
      out.write("</td>\n\t    ");
      out.write("<td class=\"tableText\">");
      out.write("<input type=\"text\" name=\"maintcontract\" value=\"");
      out.print(asset.getMaintContract());
      out.write("\" size=\"20\" maxlength=\"64\"/>");
      out.write("</td>\n\t    ");
      out.write("<td class=\"tableText\">");
      out.write("<span class=\"formText\">Contract Expires:");
      out.write("</span>");
      out.write("</td>\n\t    ");
      out.write("<td class=\"tableText\">");
      out.write("<input type=\"text\" name=\"maintcontractexpires\" value=\"");
      out.print(asset.getMaintContractExpires());
      out.write("\" size=\"20\" maxlength=\"64\"/>");
      out.write("</td>\n\t    ");
      out.write("<td class=\"tableText\">");
      out.write("<span class=\"formText\">Maint Phone:");
      out.write("</span>");
      out.write("</td>\n\t    ");
      out.write("<td class=\"tableText\">");
      out.write("<input type=\"text\" name=\"supportphone\" value=\"");
      out.print(asset.getSupportPhone());
      out.write("\" size=\"20\" maxlength=\"64\"/>");
      out.write("</td>\n\t  ");
      out.write("</tr>\n\t  ");
      out.write("<tr class=\"tableRowLight\">\n\t    ");
      out.write("<td class=\"tableText\" colspan=\"6\">");
      out.write(
          "<img src=\"/wt-portal/images/spacers/spacer.gif\" height=\"4\" width=\"10\" border=\"0\" alt=\"WebTelemetry\">");
      out.write("</td>\n\t  ");
      out.write("</tr>\n\t");
      out.write("</table>");
      out.write("<br />\n\n\t");
      out.write("<table width=\"98%\" cellspacing=\"0\" cellpadding=\"2\" border=\"0\">\n\t  ");
      out.write("<tr>\n\t\t");
      out.write("<td colspan=\"3\">");
      out.write("<br />\n\t\t\t");
      out.write("<INPUT type=\"hidden\" name=\"button\" value=\"\">\n\t\t\t");
      out.write(
          "<INPUT type=\"image\" src=\"/wt-portal/images/buttons/btn_save_changes.gif\" onClick=\"document.sysInfo.button.value='Save Changes';\">\n\t\t\t&nbsp;&nbsp;&nbsp;\n\t\t\t");
      out.write(
          "<a href=\"javascript:document.sysInfo.reset()\" onClick=\"javascript:document.sysInfo.reset();\">");
      out.write("<img src=\"/wt-portal/images/buttons/btn_reset.gif\" border=\"0\" alt=\"Reset\">");
      out.write("</a>");
      out.write("<br />&nbsp;\n\t\t\t");
      out.write("<!-- ");
      out.write("<input type=\"submit\" value=\"Save Changes\"/>\n\t\t\t");
      out.write("<input type=\"reset\" /> -->\n\t\t");
      out.write("</td>\n\t\t");
      out.write("<td colspan=\"3\" align=\"right\" class=\"message\">");
      out.write("<br />\n\t\t\t");
      if (isNew) {
        out.write("\n\t\t\t\tNew Record\n\t\t\t");
      } else {
        out.write("\n\t\t\t\tLast Modified: ");
        out.print(WTTools.formatLocalDateToString(asset.getLastModifiedDate()));
        out.write(" by ");
        out.print(asset.getUserLastModified());
        out.write("\n\t\t\t");
      }
      out.write("\n\t\t");
      out.write("</td>\n\t  ");
      out.write("</tr>\n\t");
      out.write("</table>\n\t");
      out.write("</form>\n\n");
      out.write("<!-- BEGIN FRAMING TABLE:close tags-->\n\t\t");
      out.write("</td>\n\t");
      out.write("</tr>\n");
      out.write("</table>\n");
      out.write("<!-- END FRAMING TABLE:close tags-->\n\n");
      out.write("<br>\n");
      JspRuntimeLibrary.include(request, response, "/includes/footer.jsp", out, false);
      out.write("\n\n");
      out.write("</body>\n");
      out.write("</html>\n");
    } catch (Throwable t) {
      out = _jspx_out;
      if (out != null && out.getBufferSize() != 0) out.clearBuffer();
      if (pageContext != null) pageContext.handlePageException(t);
    } finally {
      if (_jspxFactory != null) _jspxFactory.releasePageContext(pageContext);
    }
  }
  /** {@inheritDoc} */
  public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response)
      throws IOException {

    ThreadCategory.setPrefix(MapsConstants.LOG4J_CATEGORY);
    log = ThreadCategory.getInstance(this.getClass());
    String action = request.getParameter("action");
    String elems = request.getParameter("elems");
    log.debug("Adding Nodes action:" + action + ", elems=" + elems);

    BufferedWriter bw =
        new BufferedWriter(new OutputStreamWriter(response.getOutputStream(), "UTF-8"));
    try {
      Integer[] nodeids = null;

      boolean actionfound = false;

      if (action.equals(MapsConstants.ADDNODES_ACTION)) {
        log.debug("Adding nodes by id: " + elems);
        actionfound = true;
        String[] snodeids = elems.split(",");
        nodeids = new Integer[snodeids.length];
        for (int i = 0; i < snodeids.length; i++) {
          nodeids[i] = new Integer(snodeids[i]);
        }
      }

      if (action.equals(MapsConstants.ADDNODES_BY_CATEGORY_ACTION)) {
        log.debug("Adding nodes by category: " + elems);
        actionfound = true;
        String categoryName = elems;
        CategoryFactory.init();
        CatFactory cf = CategoryFactory.getInstance();
        cf.getReadLock().lock();
        try {
          final String rule = cf.getEffectiveRule(categoryName);
          final List<InetAddress> nodeIPs = FilterDaoFactory.getInstance().getIPAddressList(rule);
          LogUtils.debugf(this, "ips found: %s", nodeIPs.toString());
          nodeids = new Integer[nodeIPs.size()];
          for (int i = 0; i < nodeIPs.size(); i++) {
            final InetAddress nodeIp = nodeIPs.get(i);
            final List<Integer> ids =
                NetworkElementFactory.getInstance(getServletContext())
                    .getNodeIdsWithIpLike(InetAddressUtils.str(nodeIp));
            LogUtils.debugf(this, "Ids by ipaddress %s: %s", nodeIp, ids.toString());
            nodeids[i] = ids.get(0);
          }
        } finally {
          cf.getReadLock().unlock();
        }
      }

      if (action.equals(MapsConstants.ADDNODES_BY_LABEL_ACTION)) {
        log.debug("Adding nodes by label: " + elems);
        actionfound = true;
        List<OnmsNode> nodes = NetworkElementFactory.getInstance(getServletContext()).getAllNodes();
        nodeids = new Integer[nodes.size()];
        for (int i = 0; i < nodes.size(); i++) {
          nodeids[i] = nodes.get(i).getId();
        }
      }

      if (action.equals(MapsConstants.ADDRANGE_ACTION)) {
        log.debug("Adding nodes by range: " + elems);
        actionfound = true;
        nodeids =
            (Integer[])
                NetworkElementFactory.getInstance(getServletContext())
                    .getNodeIdsWithIpLike(elems)
                    .toArray(new Integer[0]);
      }

      if (action.equals(MapsConstants.ADDNODES_NEIG_ACTION)) {
        log.debug("Adding nodes neighbor of:" + elems);
        actionfound = true;
        nodeids =
            (Integer[])
                NetworkElementFactory.getInstance(getServletContext())
                    .getLinkedNodeIdOnNode(WebSecurityUtils.safeParseInt(elems))
                    .toArray(new Integer[0]);
      }

      if (action.equals(MapsConstants.ADDNODES_WITH_NEIG_ACTION)) {
        log.debug("Adding nodes with neighbor of:" + elems);
        actionfound = true;
        Set<Integer> linkednodeids =
            NetworkElementFactory.getInstance(getServletContext())
                .getLinkedNodeIdOnNode(WebSecurityUtils.safeParseInt(elems));
        linkednodeids.add(new Integer(elems));
        nodeids = linkednodeids.toArray(new Integer[linkednodeids.size()]);
      }

      VMap map = manager.openMap();
      if (log.isDebugEnabled()) log.debug("Got map from manager " + map);

      List<VElement> velems = new ArrayList<VElement>();
      // response for addElement
      if (actionfound) {
        log.debug("Before Checking map contains elems");

        for (int i = 0; i < nodeids.length; i++) {
          int elemId = nodeids[i].intValue();
          if (map.containsElement(elemId, MapsConstants.NODE_TYPE)) {
            log.debug(
                "Action: "
                    + action
                    + " . Map Contains Element: "
                    + elemId
                    + MapsConstants.NODE_TYPE);
            continue;
          }

          velems.add(manager.newElement(map.getId(), elemId, MapsConstants.NODE_TYPE));
        } // end for

        // get links and add elements to map
        map = manager.addElements(map, velems);
        log.debug("After getting/adding links");

        bw.write(ResponseAssembler.getAddElementResponse(null, velems, map.getLinks()));
      }
    } catch (Throwable e) {
      log.error("Error while adding nodes for action: " + action, e);
      bw.write(ResponseAssembler.getMapErrorResponse(action));
    } finally {
      bw.close();
    }

    return null;
  }
  /** {@inheritDoc} */
  @Override
  public void doPost(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    String nodeIdString = request.getParameter("node");
    String labelType = request.getParameter("labeltype");
    String userLabel = request.getParameter("userlabel");

    if (nodeIdString == null) {
      throw new MissingParameterException("node", new String[] {"node", "labeltype", "userlabel"});
    }
    if (labelType == null) {
      throw new MissingParameterException(
          "labeltype", new String[] {"node", "labeltype", "userlabel"});
    }
    if (userLabel == null) {
      throw new MissingParameterException(
          "userlabel", new String[] {"node", "labeltype", "userlabel"});
    }

    try {
      final int nodeId = WebSecurityUtils.safeParseInt(nodeIdString);
      final OnmsNode node = NetworkElementFactory.getInstance(getServletContext()).getNode(nodeId);
      NodeLabelJDBCImpl oldLabel = new NodeLabelJDBCImpl(node.getLabel(), node.getLabelSource());
      NodeLabelJDBCImpl newLabel = null;

      if (labelType.equals("auto")) {
        newLabel = NodeLabelJDBCImpl.getInstance().computeLabel(nodeId);
      } else if (labelType.equals("user")) {
        newLabel = new NodeLabelJDBCImpl(userLabel, NodeLabelSource.USER);
      } else {
        throw new ServletException("Unexpected labeltype value: " + labelType);
      }

      final String newNodeLabel = newLabel.getLabel();
      boolean managedByProvisiond = node.getForeignSource() != null && node.getForeignId() != null;
      if (managedByProvisiond) {
        WebApplicationContext beanFactory =
            WebApplicationContextUtils.getWebApplicationContext(getServletContext());
        final TransactionTemplate transactionTemplate =
            beanFactory.getBean(TransactionTemplate.class);
        final RequisitionAccessService requisitionService =
            beanFactory.getBean(RequisitionAccessService.class);
        transactionTemplate.execute(
            new TransactionCallback<RequisitionNode>() {
              @Override
              public RequisitionNode doInTransaction(TransactionStatus status) {
                MultivaluedMapImpl params = new MultivaluedMapImpl();
                params.putSingle("node-label", newNodeLabel);
                requisitionService.updateNode(node.getForeignSource(), node.getForeignId(), params);
                return requisitionService.getNode(node.getForeignSource(), node.getForeignId());
              }
            });
      }

      this.sendLabelChangeEvent(nodeId, oldLabel, newLabel);

      if (managedByProvisiond) {
        response.sendRedirect(
            Util.calculateUrlBase(
                request,
                "admin/nodelabelProvisioned.jsp?node="
                    + nodeIdString
                    + "&foreignSource="
                    + node.getForeignSource()));
      } else {
        NodeLabelJDBCImpl.getInstance().assignLabel(nodeId, newLabel);
        response.sendRedirect(
            Util.calculateUrlBase(request, "element/node.jsp?node=" + nodeIdString));
      }
    } catch (SQLException e) {
      throw new ServletException("Database exception", e);
    } catch (Throwable e) {
      throw new ServletException("Exception sending node label change event", e);
    }
  }