use of javax.servlet.RequestDispatcher in project opennms by OpenNMS.
the class AddNewInterfaceServlet method doPost.
/**
* {@inheritDoc}
*/
@Override
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
int nodeId = -1;
String ipAddress = request.getParameter("ipAddress");
try {
nodeId = getNodeId(ipAddress);
} catch (SQLException sqlE) {
throw new ServletException("AddInterfaceServlet: failed to query if the ipaddress already exists", sqlE);
}
if (nodeId != -1) {
RequestDispatcher dispatcher = this.getServletContext().getRequestDispatcher("/admin/newInterface.jsp?action=redo");
dispatcher.forward(request, response);
} else {
createAndSendNewSuspectInterfaceEvent(ipAddress);
// forward the request for proper display
RequestDispatcher dispatcher = this.getServletContext().getRequestDispatcher("/admin/interfaceAdded.jsp");
dispatcher.forward(request, response);
}
}
use of javax.servlet.RequestDispatcher in project opennms by OpenNMS.
the class SetCriticalPathServlet method doPost.
/**
* {@inheritDoc}
*/
@Override
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String nodeString = request.getParameter("node");
String criticalIp = InetAddressUtils.normalize(request.getParameter("criticalIp"));
String criticalSvc = request.getParameter("criticalSvc");
String task = request.getParameter("task");
int node = -1;
try {
node = WebSecurityUtils.safeParseInt(nodeString);
} catch (NumberFormatException numE) {
throw new ServletException(numE);
}
if (task.equals("Delete")) {
try {
deleteCriticalPath(node);
} catch (SQLException e) {
throw new ServletException("SetCriticalPathServlet: Error writing to database." + e);
}
} else if (task.equals("Submit")) {
try {
setCriticalPath(node, criticalIp, criticalSvc);
} catch (SQLException e) {
throw new ServletException("SetCriticalPathServlet: Error writing to database." + e);
}
} else {
RequestDispatcher dispatcher = this.getServletContext().getRequestDispatcher("/admin/nodemanagement/setPathOutage.jsp?node=" + node + "&task=Requested operation " + task + " not understood.");
dispatcher.forward(request, response);
return;
}
RequestDispatcher dispatcher = this.getServletContext().getRequestDispatcher("/admin/nodemanagement/index.jsp?node=" + node);
dispatcher.forward(request, response);
}
use of javax.servlet.RequestDispatcher in project opennms by OpenNMS.
the class SnmpGetNodesServlet method doPost.
/**
* {@inheritDoc}
*/
@Override
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
HttpSession user = request.getSession(true);
try {
user.setAttribute("listAllnodes.snmpmanage.jsp", getAllNodes(user));
} catch (SQLException e) {
throw new ServletException(e);
}
// forward the request for proper display
RequestDispatcher dispatcher = this.getServletContext().getRequestDispatcher("/admin/snmpmanage.jsp");
dispatcher.forward(request, response);
}
use of javax.servlet.RequestDispatcher in project opennms by OpenNMS.
the class SnmpManageNodesServlet method doPost.
/**
* {@inheritDoc}
*/
@Override
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
HttpSession userSession = request.getSession(false);
List<SnmpManagedInterface> allInterfaces = getManagedInterfacesFromSession(userSession);
// the node being modified
String nodeIdString = request.getParameter("node");
int currNodeId = WebSecurityUtils.safeParseInt(nodeIdString);
String primeInt = null;
for (final SnmpManagedInterface testInterface : allInterfaces) {
if (testInterface.getNodeid() == currNodeId && PrimaryType.PRIMARY.getCode().equals(testInterface.getStatus())) {
// Get the IP address of the primary SNMP interface
primeInt = NetworkElementFactory.getInstance(this.getServletContext()).getIpPrimaryAddress(currNodeId);
}
}
final DBUtils d = new DBUtils(getClass());
try {
Connection connection = DataSourceFactory.getInstance().getConnection();
d.watch(connection);
try {
connection.setAutoCommit(false);
PreparedStatement stmt = connection.prepareStatement(UPDATE_INTERFACE);
d.watch(stmt);
for (SnmpManagedInterface curInterface : allInterfaces) {
String option = request.getParameter("collect-" + curInterface.getIfIndex());
LOG.debug("option = {}", option);
stmt.setString(1, option);
stmt.setInt(2, curInterface.getSnmpInterfaceId());
stmt.execute();
}
connection.commit();
} finally {
// close off the db connection
connection.setAutoCommit(true);
}
} catch (SQLException e) {
throw new ServletException(e);
} finally {
d.cleanUp();
}
// send the event to restart SNMP Collection
if (primeInt != null) {
sendSNMPRestartEvent(currNodeId, primeInt);
}
// forward the request for proper display
// TODO This will redirect to the node page, but the URL will be admin/changeCollectStatus. Needs fixed.
RequestDispatcher dispatcher = this.getServletContext().getRequestDispatcher("/element/node.jsp?node=" + currNodeId);
dispatcher.forward(request, response);
}
use of javax.servlet.RequestDispatcher in project opennms by OpenNMS.
the class ModifyUserServlet method doPost.
/**
* {@inheritDoc}
*/
@Override
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
HttpSession userSession = request.getSession(true);
try {
UserFactory.init();
UserManager userFactory = UserFactory.getInstance();
User user = userFactory.getUser(request.getParameter("userID"));
userSession.setAttribute("user.modifyUser.jsp", user);
} catch (Throwable e) {
throw new ServletException("Couldn't initialize UserFactory", e);
}
// forward the request for proper display
RequestDispatcher dispatcher = this.getServletContext().getRequestDispatcher("/admin/userGroupView/users/modifyUser.jsp");
dispatcher.forward(request, response);
}
Aggregations