/** * renders an action set as a user readable html string, occurs when * editing existing slas * * @param items * @return */ public static String BuildSLAAction(List<SLAAction> items, PCS pcs, SecurityWrapper c) { String s = ""; for (int i = 0; i < items.size(); i++) { if (items.get(i) instanceof SLAAction) { GetPluginInformationResponseMsg GetPluginInfo = GetPluginInfo(items.get(i).getImplementingClassName(), "SLA_ACTION", pcs, c); if (GetPluginInfo == null) { s += "Unknown SLA Action<br>"; } else { s += GetPluginInfo.getDisplayName() + "<br>"; } } } return s; }
/** * used on manage.jsp to render SLA info in the tab'd box * * @param item * @return */ public static String BuildSLASingleAction(SLAAction item, PCS pcs, SecurityWrapper c) { String s = ""; GetPluginInformationResponseMsg GetPluginInfo = GetPluginInfo(item.getImplementingClassName(), "SLA_ACTION", pcs, c); if (GetPluginInfo == null) { return "Unknown SLA Action"; } return GetPluginInfo.getDisplayName(); }
/** * does this action list contain an email SLA * * @param pc * @return */ public static boolean hasEmailSLA(ArrayOfSLAActionBaseType pc) { if (pc == null) { return false; } if (pc.getSLAAction().isEmpty()) { return false; } for (int i = 0; i < pc.getSLAAction().size(); i++) { if (pc.getSLAAction().get(i).getImplementingClassName().equals("org.miloss.fgsms.sla.actions.EmailAlerter")) { return true; } } return false; }
if (Utility.stringIsNullOrEmpty(action.get(i).getImplementingClassName())) { ref.set(ref.get() + " action class name is not defined"); return false; cmd.setString(1, action.get(i).getImplementingClassName()); cmd.setString(2, "SLA_ACTION"); rs = cmd.executeQuery(); ref.set(ref.get() + " The specified action, class name=" + action.get(i).getImplementingClassName() + " is not registered"); return false; Class<SLAActionInterface> forName = (Class<SLAActionInterface>) Class.forName(action.get(i).getImplementingClassName()); SLAActionInterface newInstance = forName.newInstance(); if (!newInstance.GetAppliesTo().contains(pol.getPolicyType())) { ref.set(ref.get() + " The specified action, class name=" + action.get(i).getImplementingClassName() + " does not apply to the policy type of " + pol.getPolicyType().value()); return false; ref.set(ref.get() + " The specified action, class name=" + action.get(i).getImplementingClassName() + " could not be loaded, " + ex.getMessage()); return false;
log.debug("Processing alert for " + alert.getModifiedurl() + " msg " + alert.getFaultMsg() + " class " + alert.getSlaActionBaseType().getImplementingClassName()); Class c = null; try { c = Thread.currentThread().getContextClassLoader().loadClass(alert.getSlaActionBaseType().getImplementingClassName()); } catch (ClassNotFoundException ex) { c = this.getClass().getClassLoader().loadClass(alert.getSlaActionBaseType().getImplementingClassName()); } catch (ClassNotFoundException ex) { c = Class.forName(alert.getSlaActionBaseType().getImplementingClassName()); } catch (ClassNotFoundException ex) { log.error("Error to Load class for SLA Alert!!!" + alert.getSlaActionBaseType().getImplementingClassName()); } else { try {
/** * does this policy have an email sla action? * * @param pc * @return */ public static boolean hasEmailSLA(ServicePolicy pc) { if (pc == null) { return false; } if (pc.getServiceLevelAggrements() == null || pc.getServiceLevelAggrements().getSLA().isEmpty()) { return false; } for (int i = 0; i < pc.getServiceLevelAggrements().getSLA().size(); i++) { if (pc.getServiceLevelAggrements().getSLA().get(i).getAction() != null && !pc.getServiceLevelAggrements().getSLA().get(i).getAction().getSLAAction().isEmpty()) { for (int k = 0; k < pc.getServiceLevelAggrements().getSLA().get(i).getAction().getSLAAction().size(); k++) { if (pc.getServiceLevelAggrements().getSLA().get(i).getAction().getSLAAction().get(k).getImplementingClassName().equals("org.miloss.fgsms.sla.actions.EmailAlerter")) { return true; } } } } return false; }
/** * * @param action * @param pcs * @param c * @param item_type FEDERATION_PUBLISH,SLA_RULE,SLA_ACTION * @return html escaped friendly name of the plugin */ public static String ToFriendlyName(SLAAction action, PCS pcs, SecurityWrapper c) { if (action == null) { return "Null Action"; } GetPluginInformationRequestMsg req = new GetPluginInformationRequestMsg(); req.setGetPluginInformationRequestWrapper(new GetPluginInformationRequestWrapper()); req.getGetPluginInformationRequestWrapper().setClassification(c); req.getGetPluginInformationRequestWrapper().setPlugin(new Plugin()); req.getGetPluginInformationRequestWrapper().getPlugin().setClassname(action.getImplementingClassName()); req.getGetPluginInformationRequestWrapper().getPlugin().setPlugintype("SLA_ACTION"); GetPluginInformation r = new GetPluginInformation(); r.setRequest(req); try { GetPluginInformationResponse pluginInformation = pcs.getPluginInformation(r); return Utility.encodeHTML(pluginInformation.getResponse().getDisplayName()); } catch (Exception ex) { LogHelper.getLog().error(ex); } return "Unrecognized action, " + Utility.encodeHTML(action.getImplementingClassName()); }
/** * * @param action * @param pcs * @param c * @param item_type FEDERATION_PUBLISH,SLA_RULE,SLA_ACTION * @return */ public static String GetPluginHelp(SLAAction action, PCS pcs, SecurityWrapper c, String item_type) { if (action == null) { return "Null Action"; } GetPluginInformationRequestMsg req = new GetPluginInformationRequestMsg(); req.setGetPluginInformationRequestWrapper(new GetPluginInformationRequestWrapper()); req.getGetPluginInformationRequestWrapper().setClassification(c); req.getGetPluginInformationRequestWrapper().setPlugin(new Plugin()); req.getGetPluginInformationRequestWrapper().getPlugin().setClassname(action.getImplementingClassName()); req.getGetPluginInformationRequestWrapper().getPlugin().setPlugintype(item_type); GetPluginInformation r = new GetPluginInformation(); r.setRequest(req); try { GetPluginInformationResponse pluginInformation = pcs.getPluginInformation(r); return pluginInformation.getResponse().getHelp(); } catch (Exception ex) { LogHelper.getLog().error(ex); } return "No help information could be found."; }