/** * Return a subclass of <code>InventoryHelper</code> specific to the entity type of a particular * resource. */ public static InventoryHelper getHelper(AppdefEntityID entityId) { switch (entityId.getType()) { case AppdefEntityConstants.APPDEF_TYPE_PLATFORM: return new PlatformInventoryHelper(entityId, Bootstrap.getBean(AppdefBoss.class)); case AppdefEntityConstants.APPDEF_TYPE_SERVER: return new ServerInventoryHelper(entityId, Bootstrap.getBean(AppdefBoss.class)); case AppdefEntityConstants.APPDEF_TYPE_SERVICE: return new ServiceInventoryHelper(entityId); case AppdefEntityConstants.APPDEF_TYPE_APPLICATION: return new ApplicationInventoryHelper(entityId, Bootstrap.getBean(AppdefBoss.class)); case AppdefEntityConstants.APPDEF_TYPE_GROUP: return new GroupInventoryHelper(entityId); default: throw new IllegalArgumentException(entityId.getTypeName()); } }
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); }
public boolean isResourceConfigured( HttpServletRequest request, ServletContext ctx, boolean setError) throws ServletException, AppdefEntityNotFoundException, SessionNotFoundException, SessionTimeoutException, PermissionException, EncodingException, RemoteException { final String CONFIG_ATTR = "IsResourceUnconfigured"; Boolean configured = (Boolean) request.getAttribute(CONFIG_ATTR); if (configured != null) return !configured.booleanValue(); if (entityId.isGroup()) return true; int sessionId = RequestUtils.getSessionId(request).intValue(); if (this instanceof ApplicationInventoryHelper) return true; ProductBoss productBoss = Bootstrap.getBean(ProductBoss.class); String context = request.getContextPath(); try { productBoss.getMergedConfigResponse( sessionId, ProductPlugin.TYPE_MEASUREMENT, entityId, true); } catch (ConfigFetchException e) { if (setError) { ActionMessage error = new ActionMessage( CFG_ERR_RES, new String[] { context, String.valueOf(entityId.getType()), String.valueOf(entityId.getID()) }); RequestUtils.setError(request, error, ActionMessages.GLOBAL_MESSAGE); } request.setAttribute(CONFIG_ATTR, Boolean.TRUE); return false; } // only check where the config is invalid String validationError = productBoss.getConfigResponse(sessionId, entityId).getValidationError(); if (validationError == null) { request.setAttribute(CONFIG_ATTR, Boolean.FALSE); return true; } if (setError) { ActionMessage error = new ActionMessage( CFG_INVALID_RES, new String[] { StringUtil.replace(validationError, "\n", "<br> " + " "), context, String.valueOf(entityId.getType()), String.valueOf(entityId.getID()) }); RequestUtils.setError(request, error, ActionMessages.GLOBAL_MESSAGE); } request.setAttribute(CONFIG_ATTR, Boolean.TRUE); return false; }
/** * @param count The number of times the alert conditions must be satisfied * @param timeRange The time window (in milliseconds) in which the specified count of alert * conditions must be satisfied. * @param zeventEnqueuer The {@link ZeventEnqueuer} to use for sending {@link * AlertConditionsSatisfiedZEvent}s */ public CounterExecutionStrategy(long count, long timeRange, ZeventEnqueuer zeventEnqueuer) { this(count, timeRange, zeventEnqueuer, Bootstrap.getBean(HeartbeatCurrentTime.class)); }