use of nl.nn.adapterframework.util.Lock in project iaf by ibissource.
the class ShowMonitors method executeSub.
public ActionForward executeSub(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
// Initialize action
initAction(request);
if (ibisManager == null)
return (mapping.findForward("noIbisContext"));
String forward = null;
DynaActionForm monitorForm = getPersistentForm(mapping, form, request);
if (isCancelled(request)) {
log.debug("edit is canceled");
forward = determineExitForward(monitorForm);
} else {
// debugFormData(request,form);
String action = request.getParameter("action");
String indexStr = request.getParameter("index");
String triggerIndexStr = request.getParameter("triggerIndex");
int index = -1;
if (StringUtils.isNotEmpty(indexStr)) {
index = Integer.parseInt(indexStr);
}
int triggerIndex = -1;
if (StringUtils.isNotEmpty(triggerIndexStr)) {
triggerIndex = Integer.parseInt(triggerIndexStr);
}
MonitorManager mm = MonitorManager.getInstance();
if ("getStatus".equals(action)) {
response.setContentType("text/xml");
PrintWriter out = response.getWriter();
out.print(mm.getStatusXml().toXML());
out.close();
return null;
}
Lock lock = mm.getStructureLock();
try {
lock.acquireExclusive();
forward = performAction(monitorForm, action, index, triggerIndex, response);
log.debug("forward [" + forward + "] returned from performAction");
mm.reconfigure();
} catch (Exception e) {
error("could not perform action [" + action + "] on monitorIndex [" + index + "] triggerIndex [" + triggerIndex + "]", e);
} finally {
lock.releaseExclusive();
}
if (response.isCommitted()) {
return null;
}
}
if (StringUtils.isEmpty(forward)) {
log.debug("replacing empty forward with [success]");
forward = "success";
}
initForm(monitorForm);
ActionForward af = mapping.findForward(forward);
if (af == null) {
throw new ServletException("could not find forward [" + forward + "]");
}
// Forward control to the specified success URI
log.debug("forward to [" + forward + "], path [" + af.getPath() + "]");
return (af);
}
Aggregations