/** {@inheritDoc} */
  public void doPost(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    String nodeIdString = request.getParameter("node");
    String isNewString = request.getParameter("isnew");

    if (nodeIdString == null) {
      throw new MissingParameterException("node", new String[] {"node", "isnew"});
    }

    if (isNewString == null) {
      throw new MissingParameterException("isnew", new String[] {"node", "isnew"});
    }

    int nodeId = WebSecurityUtils.safeParseInt(nodeIdString);
    boolean isNew = Boolean.valueOf(isNewString).booleanValue();

    Asset asset = this.parms2Asset(request, nodeId);

    Event evnt = EventUtils.createAssetInfoChangedEvent("OpenNMS.WebUI", nodeId, -1L);
    sendEvent(evnt);

    try {
      if (isNew) {
        this.model.createAsset(asset);
      } else {
        this.model.modifyAsset(asset);
      }

      response.sendRedirect("modify.jsp?node=" + nodeId);
    } catch (SQLException e) {
      throw new ServletException("database error", e);
    }
  }
예제 #2
0
  private boolean isReloadConfigEvent(Event event) {
    boolean isTarget = false;

    if (EventConstants.RELOAD_DAEMON_CONFIG_UEI.equals(event.getUei())) {
      if ("Eventd".equalsIgnoreCase(EventUtils.getParm(event, EventConstants.PARM_DAEMON_NAME))) {
        isTarget = true;
      }
      // Deprecating this one...
    } else if (EventConstants.EVENTSCONFIG_CHANGED_EVENT_UEI.equals(event.getUei())) {
      isTarget = true;
    }

    return isTarget;
  }