public void execute(JsonActionContext context) throws Exception { Map p = context.getParameterMap(); if (_log.isDebugEnabled()) { for (Iterator i = p.entrySet().iterator(); i.hasNext(); ) { Map.Entry ent = (Map.Entry) i.next(); _log.debug("key=" + ent.getKey() + " val=" + ArrayUtil.toString((Object[]) ent.getValue())); } } String name = ((String[]) p.get("name"))[0]; String desc = ((String[]) p.get("description"))[0]; long maxWait = Long.parseLong(((String[]) p.get("maxWaitTime"))[0]); boolean pausable = Boolean.valueOf(((String[]) p.get("allowPause"))[0]).booleanValue(); boolean notifyAll = Boolean.valueOf(((String[]) p.get("notifyAll"))[0]).booleanValue(); boolean repeat = Boolean.valueOf(((String[]) p.get("repeat"))[0]).booleanValue(); Integer id = Integer.valueOf(((String[]) p.get(ID))[0]); EventsBoss eBoss = Bootstrap.getBean(EventsBoss.class); Escalation escalation = eBoss.findEscalationById(context.getSessionId(), id); JSONObject result; try { eBoss.updateEscalation( context.getSessionId(), escalation, name, desc, maxWait, pausable, notifyAll, repeat); result = Escalation.getJSON(escalation); } catch (DuplicateObjectException exception) { // An escalation by this name already exists show error msg. result = new JSONObject(); result.put("error", "An escalation with this name already exists."); } context.setJSONResult(new JSONResult(result)); context.getRequest().setAttribute(Escalation.JSON_NAME, result); }
/** * Return the array of Integer ids for the given <code>notificationType</code> contained in the * alert definition notification actions. * * <p>This method also sets the alert definition object on the form and places it in the request. * It also puts the resource id and resource type in the request. * * @param addForm the form being prepared * @param notificationType the type of notification * @return the array of ids for already existing notifications based on the notificationType, or a * zero-length array if there are not yet any notifications of this type * @throws ServletException * @throws RemoteException * @throws PermissionException * @throws SessionTimeoutException * @throws SessionNotFoundException * @throws EncodingException * @throws InvalidActionDataException */ public Integer[] getNotificationIds( HttpServletRequest request, AddNotificationsFormNG addForm, AppdefEntityID aeid, int notificationType) throws ServletException, SessionNotFoundException, SessionTimeoutException, PermissionException, RemoteException, EncodingException, InvalidActionDataException { Integer[] ids = new Integer[0]; Integer sessionId = RequestUtils.getSessionId(request); Integer alertDefId = addForm.getAd(); log.debug("(1) alertDefId=" + alertDefId); if (alertDefId == null) throw new ParameterNotFoundException("alert definition id not found"); log.debug("(2) alertDefId=" + alertDefId); AlertDefinitionValue alertDef = (AlertDefinitionValue) request.getAttribute(Constants.ALERT_DEFS_ATTR); if (alertDef == null) { alertDef = eventsBoss.getAlertDefinition(sessionId.intValue(), alertDefId); } request.setAttribute(Constants.ALERT_DEFINITION_ATTR, alertDef); ActionValue[] actions = alertDef.getActions(); for (int i = 0; i < actions.length; ++i) { if (actions[i].classnameHasBeenSet() && !(actions[i].getClassname().equals(null) || actions[i].getClassname().equals(""))) { EmailActionConfig emailCfg = new EmailActionConfig(); ConfigResponse configResponse = ConfigResponse.decode(actions[i].getConfig()); try { emailCfg.init(configResponse); } catch (InvalidActionDataException e) { // Not an EmailAction log.debug("Action is " + actions[i].getClassname()); continue; } if (emailCfg.getType() == notificationType) { ids = new Integer[emailCfg.getUsers().size()]; ids = (Integer[]) emailCfg.getUsers().toArray(ids); break; } } } if (aeid instanceof AppdefEntityTypeID) { addForm.setAetid(aeid.getAppdefKey()); request.setAttribute(Constants.APPDEF_RES_TYPE_ID, aeid.getAppdefKey()); } else { addForm.setRid(aeid.getId()); addForm.setType(new Integer(aeid.getType())); request.setAttribute(Constants.ENTITY_ID_PARAM, aeid.getAppdefKey()); } return ids; }
public String execute() throws Exception { log.debug("entering RemoveEscalationActionNG"); Integer escId = RequestUtils.getIntParameter(request, "esc"); Integer sessionId = RequestUtils.getSessionId(request); try { eventsBoss.deleteEscalationById(sessionId.intValue(), escId); } catch (Exception e) { addActionError(getText("admin.config.error.escalation.CannotDelete")); } return SUCCESS; }